commit d9d4f0108ccea40b90bc91e2dde37e07f91495dc
parent bfcda0f985e147f8330f55071ccfb282cb31997d
Author: Naveen Narayanan <zerous@nocebo.space>
Date: Wed, 13 Oct 2021 15:32:00 +0200
Check for malformed ip in black/whitelist
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/main.c b/main.c
@@ -11,6 +11,7 @@
#include "attack.h"
#include "config.h"
#include "fw.h"
+#include "ip.h"
#include "parser.h"
#include "queue.h"
@@ -171,6 +172,8 @@ main(int argc, char **argv)
* Attackers generated from blacklist
* will have nban and last set to 0
*/
+ if (!isip(bf))
+ errx(1, "malformed ip in blacklist");
strcpy(a->ip, bf);
a->list = BLACK;
fw_block(a->ip);
@@ -192,6 +195,8 @@ main(int argc, char **argv)
* Attackers generated from whitelist
* will have nban and last set to 0
*/
+ if (!isip(bf))
+ errx(1, "malformed ip in whitelist");
strcpy(a->ip, bf);
a->list = WHITE;
SLIST_INSERT_HEAD(&head, a, attackers);