Skip to content

Commit 3f6b8a6

Browse files
matvoregitster
authored andcommitted
url: do not read past end of buffer
url_decode_internal could have been tricked into reading past the length of the **query buffer if there are fewer than 2 characters after a % (in a null-terminated string, % would have to be the last character). Prevent this from happening by checking len before decoding the % sequence. Helped-by: René Scharfe <[email protected]> Signed-off-by: Matthew DeVore <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aeb582a commit 3f6b8a6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

url.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static char *url_decode_internal(const char **query, int len,
4646
break;
4747
}
4848

49-
if (c == '%') {
49+
if (c == '%' && (len < 0 || len >= 3)) {
5050
int val = hex2chr(q + 1);
5151
if (0 <= val) {
5252
strbuf_addch(out, val);

0 commit comments

Comments
 (0)