Skip to content

Commit 34e8d99

Browse files
committed
Merge branch 'jc/url-match'
While normalizing a URL, we forgot that the buffer that holds it could be relocated when it grows, which was a brown-paper-bag bug that can lead to a crash introduced on 'master' post 1.8.4 release. * jc/url-match: urlmatch.c: recompute pointer after append_normalized_escapes
2 parents 2f46b53 + a7f0a0e commit 34e8d99

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

urlmatch.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,11 @@ char *url_normalize(const char *url, struct url_info *out_info)
281281
url_len--;
282282
}
283283
for (;;) {
284-
const char *seg_start = norm.buf + norm.len;
284+
const char *seg_start;
285+
size_t seg_start_off = norm.len;
285286
const char *next_slash = url + strcspn(url, "/?#");
286287
int skip_add_slash = 0;
288+
287289
/*
288290
* RFC 3689 indicates that any . or .. segments should be
289291
* unescaped before being checked for.
@@ -297,6 +299,8 @@ char *url_normalize(const char *url, struct url_info *out_info)
297299
strbuf_release(&norm);
298300
return NULL;
299301
}
302+
303+
seg_start = norm.buf + seg_start_off;
300304
if (!strcmp(seg_start, ".")) {
301305
/* ignore a . segment; be careful not to remove initial '/' */
302306
if (seg_start == path_start + 1) {

0 commit comments

Comments
 (0)