From 1ab5387ff06d5aaa5d569e649b577df782a4eaf8 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sun, 27 Aug 2023 23:07:02 -0300 Subject: [PATCH] Fix cidr edge cases --- src/iscidraddr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/iscidraddr.c b/src/iscidraddr.c index ccd01ae..3d889bd 100644 --- a/src/iscidraddr.c +++ b/src/iscidraddr.c @@ -35,6 +35,10 @@ in_range(char buf[4], int min, int max) char *err; long r; errno = 0; - r = strtol(buf, &err, 10); - return *err == '\0' && errno == 0 && (r >= min && r <= max); + if (strnlen(buf, 1) == 0) { + return 0; + } else { + r = strtol(buf, &err, 10); + return *err == '\0' && errno == 0 && (r >= min && r <= max); + } }