slash = strchr(check, '/');
/* if the slash is part of this token, use it */
if(slash) {
- /* if the bits variable gets a crazy value here, that is fine as
- the value will then be rejected in the cidr function */
- bits = (unsigned int)atoi(slash + 1);
+ curl_off_t value;
+ const char *p = &slash[1];
+ if(curlx_str_number(&p, &value, 128) || *p)
+ return FALSE;
+ /* a too large value is rejected in the cidr function below */
+ bits = (unsigned int)value;
*slash = 0; /* null-terminate there */
}
if(type == TYPE_IPV6)
{ "foobar", "foobar", TRUE},
{ "192.168.0.1", "foobar", FALSE},
{ "192.168.0.1", "192.168.0.0/16", TRUE},
+ { "192.168.0.1", "192.168.0.0/16a", FALSE},
+ { "192.168.0.1", "192.168.0.0/16 ", TRUE},
+ { "192.168.0.1", "192.168.0.0/a16", FALSE},
+ { "192.168.0.1", "192.168.0.0/ 16", FALSE},
{ "192.168.0.1", "192.168.0.0/24", TRUE},
{ "192.168.0.1", "192.168.0.0/32", FALSE},
+ { "192.168.0.1", "192.168.0.1/32", TRUE},
+ { "192.168.0.1", "192.168.0.1/33", FALSE},
{ "192.168.0.1", "192.168.0.0", FALSE},
{ "192.168.1.1", "192.168.0.0/24", FALSE},
{ "192.168.1.1", "192.168.0.0/33", FALSE},
{ "[::1]", "foo, bar, ::1/64", TRUE},
{ "[::1]", "::1/64", TRUE},
{ "[::1]", "::1/96", TRUE},
+ { "[::1]", "::1/129", FALSE},
+ { "[::1]", "::1/128", TRUE},
{ "[::1]", "::1/127", TRUE},
+ { "[::1]", "::1/a127", FALSE},
+ { "[::1]", "::1/127a", FALSE},
+ { "[::1]", "::1/ 127", FALSE},
+ { "[::1]", "::1/127 ", TRUE},
{ "[::1]", "::1/126", TRUE},
{ "[::1]", "::1/125", TRUE},
{ "[::1]", "::1/124", TRUE},