Apply a small optimization to iscidraddr.c

This commit is contained in:
0x1eef 2023-08-27 22:57:58 -03:00
parent f4fb9fc6ea
commit 97a2f8f42e
2 changed files with 3 additions and 1 deletions

View file

@ -9,11 +9,12 @@ int
iscidraddr(const char *str)
{
size_t offset = 0;
size_t len = (str == NULL ? 0 : strnlen(str, 20));
size_t len = (str == NULL ? 0 : strnlen(str, 16));
for(size_t i = 0; i < len; i++) {
if(str[i] == '/') {
offset = i;
break;
}
}
if (offset == 0) {

View file

@ -11,6 +11,7 @@ const char *valid[] = {
/* valid cidr notation */
"10.0.0.1/8", "10.0.0.1/16",
"10.0.0.1/24", "10.0.0.1/32",
"255.255.255.255/32"
};
const char *invalid[] = {