Apply a small optimization to iscidraddr.c
This commit is contained in:
parent
f4fb9fc6ea
commit
97a2f8f42e
2 changed files with 3 additions and 1 deletions
|
@ -9,11 +9,12 @@ int
|
||||||
iscidraddr(const char *str)
|
iscidraddr(const char *str)
|
||||||
{
|
{
|
||||||
size_t offset = 0;
|
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++) {
|
for(size_t i = 0; i < len; i++) {
|
||||||
if(str[i] == '/') {
|
if(str[i] == '/') {
|
||||||
offset = i;
|
offset = i;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ const char *valid[] = {
|
||||||
/* valid cidr notation */
|
/* valid cidr notation */
|
||||||
"10.0.0.1/8", "10.0.0.1/16",
|
"10.0.0.1/8", "10.0.0.1/16",
|
||||||
"10.0.0.1/24", "10.0.0.1/32",
|
"10.0.0.1/24", "10.0.0.1/32",
|
||||||
|
"255.255.255.255/32"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *invalid[] = {
|
const char *invalid[] = {
|
||||||
|
|
Loading…
Reference in a new issue