Fix cidr edge cases

This commit is contained in:
0x1eef 2023-08-27 23:07:02 -03:00
parent 97a2f8f42e
commit 1ab5387ff0

View file

@ -35,6 +35,10 @@ in_range(char buf[4], int min, int max)
char *err; char *err;
long r; long r;
errno = 0; errno = 0;
r = strtol(buf, &err, 10); if (strnlen(buf, 1) == 0) {
return *err == '\0' && errno == 0 && (r >= min && r <= max); return 0;
} else {
r = strtol(buf, &err, 10);
return *err == '\0' && errno == 0 && (r >= min && r <= max);
}
} }