diff mbox series

[firewall3] ipsets: allow commented lines with loadfile

Message ID 20201025081137.1780179-1-dharding@living180.net
State Superseded
Headers show
Series [firewall3] ipsets: allow commented lines with loadfile | expand

Commit Message

Daniel Harding Oct. 25, 2020, 8:11 a.m. UTC
When loading ipset files using the loadfile option, skip lines that
start with '#'.

Signed-off-by: Daniel Harding <dharding@living180.net>
---
 ipsets.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Henrique de Moraes Holschuh Oct. 25, 2020, 7:17 p.m. UTC | #1
On 25/10/2020 05:11, Daniel Harding wrote:
> When loading ipset files using the loadfile option, skip lines that
> start with '#'.

I suggest skipping any leading whitespace before checking for '#', 
preferably through cype.h isblank() if the codebase already uses ctype.h.

If you don't allow initial whitespace on comment lines, it can get 
confusing for users: the vast majority of formats that support comments 
starting with # up to EOL do allow whitespace before the #.
diff mbox series

Patch

diff --git a/ipsets.c b/ipsets.c
index 280845b..720f8c8 100644
--- a/ipsets.c
+++ b/ipsets.c
@@ -351,7 +351,8 @@  load_file(struct fw3_ipset *ipset)
 	}
 
 	while (fgets(line, sizeof(line), f))
-		fw3_pr("add %s %s", ipset->name, line);
+		if (line[0] != '#')
+			fw3_pr("add %s %s", ipset->name, line);
 
 	fclose(f);
 }