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>
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <ctype.h>
+
#include "ipsets.h"
{
FILE *f;
char line[128];
+ char *p;
if (!ipset->loadfile)
return;
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);
}