Skip to content

Commit f9089e8

Browse files
committed
Merge branch 'md/url-parse-harden'
The URL decoding code has been updated to avoid going past the end of the string while parsing %-<hex>-<hex> sequence. * md/url-parse-harden: url: do not allow %00 to represent NUL in URLs url: do not read past end of buffer
2 parents e694ea5 + d37dc23 commit f9089e8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

url.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ 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);
51-
if (0 <= val) {
51+
if (0 < val) {
5252
strbuf_addch(out, val);
5353
q += 3;
5454
len -= 3;

0 commit comments

Comments
 (0)