Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit a7f0a0e

Browse files
Thomas Rastgitster
authored andcommitted
urlmatch.c: recompute pointer after append_normalized_escapes
When append_normalized_escapes is called, its internal strbuf_add* calls can cause the strbuf's buf to be reallocated changing the value of the buf pointer. Do not use the strbuf buf pointer from before any append_normalized_escapes calls afterwards. Instead recompute the needed pointer. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Kyle J. McKay <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6667a6a commit a7f0a0e

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)