Browse Source

Merge branch 'md/url-parse-harden' into maint

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
maint
Junio C Hamano 6 years ago
parent
commit
d7267d55ef
  1. 4
      url.c

4
url.c

@ -46,9 +46,9 @@ static char *url_decode_internal(const char **query, int len,
break; break;
} }


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

Loading…
Cancel
Save