diff options
author | Daniel Harding <dharding@living180.net> | 2020-10-27 09:27:01 +0300 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-12-06 14:47:17 +0100 |
commit | e8f2d8f2e508a6cce7640a5dcbab9f6ef24b887b (patch) | |
tree | 98d5d05c04f647557b7b26525d7d477158ce14f6 | |
parent | 8c2f9fad9ca644af911e0d4113a890c3c84aa738 (diff) | |
download | firewall3-e8f2d8f2e508a6cce7640a5dcbab9f6ef24b887b.tar.gz |
ipsets: allow blank/commented lines with loadfile
When loading ipset files using the loadfile option, skip blank lines and
lines that start with '#' (disregarding any leading whitespace).
Signed-off-by: Daniel Harding <dharding@living180.net>
-rw-r--r-- | ipsets.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -16,6 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <ctype.h> + #include "ipsets.h" @@ -337,6 +339,7 @@ load_file(struct fw3_ipset *ipset) { FILE *f; char line[128]; + char *p; if (!ipset->loadfile) return; @@ -350,8 +353,13 @@ load_file(struct fw3_ipset *ipset) return; } - while (fgets(line, sizeof(line), f)) - fw3_pr("add %s %s", ipset->name, line); + while (fgets(line, sizeof(line), f)) { + p = line; + while (isspace(*p)) + p++; + if (*p && *p != '#') + fw3_pr("add %s %s", ipset->name, line); + } fclose(f); } |