← Commit list

97b0abb46b

Daniel Stenberg
Daniel Stenberg
2025-11-12
SUCCESS Duration: 144s

Subject

noproxy: replace atoi with curlx_str_number

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/noproxy.c+6 -3
@@ -166,9 +166,12 @@ static bool match_ip(int type, const char *token, size_t tokenlen,
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)
tests/data/test1614+1 -0
@@ -2,6 +2,7 @@
<info>
<keywords>
unittest
+noproxy
</keywords>
</info>
tests/unit/unit1614.c+12 -0
@@ -99,8 +99,14 @@ static CURLcode test_unit1614(const char *arg)
{ "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},
@@ -111,7 +117,13 @@ static CURLcode test_unit1614(const char *arg)
{ "[::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},