]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
noproxy: fix the IPV6 network mask pattern match
authorDaniel Stenberg <daniel@haxx.se>
Mon, 6 Oct 2025 14:53:27 +0000 (16:53 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 6 Oct 2025 21:49:31 +0000 (23:49 +0200)
It would mismatch if the network prefix length with was not divisible by
8.

Extended test 1614 to verify

Reported-by: Stanislav Fort
Closes #18891

lib/noproxy.c
tests/unit/unit1614.c

index 2983fa4a3aa71d25932271f27e79d554a930c575..20a335993da1969d798098f2311aa5d935f6becb 100644 (file)
@@ -99,7 +99,7 @@ UNITTEST bool Curl_cidr6_match(const char *ipv6,
     return FALSE;
   if(bytes && memcmp(address, check, bytes))
     return FALSE;
-  if(rest && !((address[bytes] ^ check[bytes]) & (0xff << (8 - rest))))
+  if(rest && ((address[bytes] ^ check[bytes]) & (0xff << (8 - rest))))
     return FALSE;
 
   return TRUE;
index 4ee18df72f17a0d2b8a348cf930350e51374013a..9ba5f95ebb62d37ea94312ba8af7beb56169c4c2 100644 (file)
@@ -111,6 +111,28 @@ static CURLcode test_unit1614(const char *arg)
     { "[::1]", "foo, bar, ::1/64", TRUE},
     { "[::1]", "::1/64", TRUE},
     { "[::1]", "::1/96", TRUE},
+    { "[::1]", "::1/127", TRUE},
+    { "[::1]", "::1/126", TRUE},
+    { "[::1]", "::1/125", TRUE},
+    { "[::1]", "::1/124", TRUE},
+    { "[::1]", "::1/123", TRUE},
+    { "[::1]", "::1/122", TRUE},
+    { "[2001:db8:8000::1]", "2001:db8::/65", FALSE},
+    { "[2001:db8:8000::1]", "2001:db8::/66", FALSE},
+    { "[2001:db8:8000::1]", "2001:db8::/67", FALSE},
+    { "[2001:db8:8000::1]", "2001:db8::/68", FALSE},
+    { "[2001:db8:8000::1]", "2001:db8::/69", FALSE},
+    { "[2001:db8:8000::1]", "2001:db8::/70", FALSE},
+    { "[2001:db8:8000::1]", "2001:db8::/71", FALSE},
+    { "[2001:db8:8000::1]", "2001:db8::/72", FALSE},
+    { "[2001:db8::1]", "2001:db8::/65", TRUE},
+    { "[2001:db8::1]", "2001:db8::/66", TRUE},
+    { "[2001:db8::1]", "2001:db8::/67", TRUE},
+    { "[2001:db8::1]", "2001:db8::/68", TRUE},
+    { "[2001:db8::1]", "2001:db8::/69", TRUE},
+    { "[2001:db8::1]", "2001:db8::/70", TRUE},
+    { "[2001:db8::1]", "2001:db8::/71", TRUE},
+    { "[2001:db8::1]", "2001:db8::/72", TRUE},
     { "[::1]", "::1/129", FALSE},
     { "bar", "foo, bar, ::1/64", TRUE},
     { "BAr", "foo, bar, ::1/64", TRUE},