Skip to content

Commit e93d30f

Browse files
committed
* Only look for a scope id inside the IPv6 address not ouside which means beyond the closing ']'
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1928016 13f79535-47bb-0310-9956-ffa450edef68
1 parent 98dd489 commit e93d30f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

uri/apr_uri.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static void percent_decode_scope_zone_id(char *hostname)
124124
memmove(hostname + offset + 1, hostname + offset + 3, len - offset - 2);
125125
}
126126

127-
static char * percent_encode_scope_zone_id(apr_pool_t *p, apr_uri_t const *uptr)
127+
static char *percent_encode_scope_zone_id(apr_pool_t *p, apr_uri_t const *uptr)
128128
{
129129
/* Inverse to the logic in the decode function, we need to encode the first
130130
* percent sign we encounter (if any).
@@ -945,9 +945,17 @@ APR_DECLARE(apr_status_t) apr_uri_parse(apr_pool_t *p, const char *uri,
945945
* unescape that.
946946
*/
947947
if (*hostinfo == '[') {
948+
apr_status_t err;
949+
950+
v6_offset1 = 1;
951+
v6_offset2 = 2;
952+
s = memchr(hostinfo, ']', uri - hostinfo);
953+
if (s == NULL) {
954+
return APR_EGENERAL;
955+
}
956+
948957
/* zone identifier */
949-
apr_status_t err = detect_scope_zone_id(&have_zone_id, hostinfo,
950-
uri - hostinfo);
958+
err = detect_scope_zone_id(&have_zone_id, hostinfo + 1, s - hostinfo - 1);
951959
/* FIXME: Ignore APR_EINVAL (invalid escaped character) for now as
952960
* old code may rely on it silently getting ignored?
953961
*/
@@ -956,12 +964,6 @@ APR_DECLARE(apr_status_t) apr_uri_parse(apr_pool_t *p, const char *uri,
956964
}
957965

958966
/* Port */
959-
v6_offset1 = 1;
960-
v6_offset2 = 2;
961-
s = memchr(hostinfo, ']', uri - hostinfo);
962-
if (s == NULL) {
963-
return APR_EGENERAL;
964-
}
965967
if (*++s != ':') {
966968
s = NULL; /* no port */
967969
}

0 commit comments

Comments
 (0)