svn commit: r1928077 - apr/apr/trunk/uri

[email protected]
Newsgroups gmane.comp.apache.apr.cvs
Message-ID <175645811452.3824878.6104634398507683831@svn02-us-east.apache.org>
Author: rpluem
Date: Fri Aug 29 09:01:54 2025
New Revision: 1928077

Log:
* Correctly identify fe80::/10 networks instead of fe80::/16

Modified:
   apr/apr/trunk/uri/apr_uri.c

Modified: apr/apr/trunk/uri/apr_uri.c
==============================================================================
--- apr/apr/trunk/uri/apr_uri.c	Fri Aug 29 08:30:17 2025	(r1928076)
+++ apr/apr/trunk/uri/apr_uri.c	Fri Aug 29 09:01:54 2025	(r1928077)
@@ -70,6 +70,12 @@ static schemes_t schemes[] =
     { NULL, 0xFFFF }     /* unknown port */
 };
 
+#define LINK_LOCAL(ipv6addr) ((strlen(ipv6addr) >= 5) && \
+                             ((ipv6addr)[4] == ':') && \
+                             !strncasecmp(ipv6addr, "fe", 2) && \
+                             strchr("89aAbB", (ipv6addr)[2]) && \
+                             strchr("0123456789aAbBcCdDeEfF", (ipv6addr)[3]))
+
 /*
  * *only* for IPv6 addresses with a zone identifier according to RFC6874
  */
@@ -89,7 +95,7 @@ static apr_status_t detect_scope_zone_id
         return APR_SUCCESS;
     }
 
-    if (strncasecmp(ipv6addr, "fe80:", 5)) {
+    if (!LINK_LOCAL(ipv6addr)) {
         /*
          * Scope id's are only allowed for link-local addresses under prefix
          * fe80::/10.
@@ -144,7 +150,7 @@ static char *percent_encode_scope_zone_i
     size_t offset;
     char *hostcopy;
 
-    if ((s == NULL) || strncasecmp(uptr->hostname, "fe80:", 5)) {
+    if ((s == NULL) || !LINK_LOCAL(uptr->hostname)) {
         /*
          * Scope id's are only allowed for link-local addresses under prefix
          * fe80::/10.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.