Skip to content

Commit c75d7ea

Browse files
committed
* Correctly identify fe80::/10 networks instead of fe80::/16
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1928077 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1c433f9 commit c75d7ea

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

uri/apr_uri.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ static schemes_t schemes[] =
7070
{ NULL, 0xFFFF } /* unknown port */
7171
};
7272

73+
#define LINK_LOCAL(ipv6addr) ((strlen(ipv6addr) >= 5) && \
74+
((ipv6addr)[4] == ':') && \
75+
!strncasecmp(ipv6addr, "fe", 2) && \
76+
strchr("89aAbB", (ipv6addr)[2]) && \
77+
strchr("0123456789aAbBcCdDeEfF", (ipv6addr)[3]))
78+
7379
/*
7480
* *only* for IPv6 addresses with a zone identifier according to RFC6874
7581
*/
@@ -89,7 +95,7 @@ static apr_status_t detect_scope_zone_id(int *have_zone_id, char const *ipv6addr
8995
return APR_SUCCESS;
9096
}
9197

92-
if (strncasecmp(ipv6addr, "fe80:", 5)) {
98+
if (!LINK_LOCAL(ipv6addr)) {
9399
/*
94100
* Scope id's are only allowed for link-local addresses under prefix
95101
* fe80::/10.
@@ -144,7 +150,7 @@ static char *percent_encode_scope_zone_id(apr_pool_t *p, apr_uri_t const *uptr)
144150
size_t offset;
145151
char *hostcopy;
146152

147-
if ((s == NULL) || strncasecmp(uptr->hostname, "fe80:", 5)) {
153+
if ((s == NULL) || !LINK_LOCAL(uptr->hostname)) {
148154
/*
149155
* Scope id's are only allowed for link-local addresses under prefix
150156
* fe80::/10.

0 commit comments

Comments
 (0)