From a0b6d847f468217b8fd675f788e6eca74a21a90c Mon Sep 17 00:00:00 2001 From: Gabriel Ganne Date: Sun, 21 Jan 2024 09:16:38 +0100 Subject: [PATCH] add check for empty cidr This causes tcprewrite to exit with an error instead of crashing. Fixes: #824 Signed-off-by: Gabriel Ganne --- src/common/cidr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/cidr.c b/src/common/cidr.c index 687fd04b..9afbfecb 100644 --- a/src/common/cidr.c +++ b/src/common/cidr.c @@ -249,6 +249,10 @@ parse_cidr(tcpr_cidr_t **cidrdata, char *cidrin, char *delim) char *network; char *token = NULL; + if (cidrin == NULL) { + errx(-1, "%s", "Unable to parse empty CIDR"); + } + mask_cidr6(&cidrin, delim); /* first iteration of input using strtok */