diff options
| author | mrg <mrg@NetBSD.org> | 2013-03-09 21:36:04 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2013-03-09 21:36:04 +0000 |
| commit | e148c60e8fcc94ba26c5b57e5872eaef4b7fc0a3 (patch) | |
| tree | fe5f70d2c84991635c4a4ddf8a39ad2e2fc7b3e6 /libexec/httpd | |
| parent | d73272d7b8749844084df0ec7820eaf5811c3cf3 (diff) | |
fix PR 47629, using a slightly different patch to the one in the PR.
this modifies escape_rfc3986() to escape '%' itself, and to properly
track the buffer size and nul out the final byte, not some random
byte that may actually be unmapped.
Diffstat (limited to 'libexec/httpd')
| -rw-r--r-- | libexec/httpd/bozohttpd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libexec/httpd/bozohttpd.c b/libexec/httpd/bozohttpd.c index 39b29c1609d..d827bd3af21 100644 --- a/libexec/httpd/bozohttpd.c +++ b/libexec/httpd/bozohttpd.c @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.c,v 1.32 2012/07/19 09:53:06 mrg Exp $ */ +/* $NetBSD: bozohttpd.c,v 1.33 2013/03/09 21:36:04 mrg Exp $ */ /* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */ @@ -871,7 +871,7 @@ escape_rfc3986(bozohttpd_t *httpd, const char *url) return buf; } - for (s = url, d = buf; *s;) { + for (len = 0, s = url, d = buf; *s;) { if (*s & 0x80) goto encode_it; switch (*s) { @@ -893,13 +893,16 @@ escape_rfc3986(bozohttpd_t *httpd, const char *url) case ',': case ';': case '=': + case '%': encode_it: snprintf(d, 4, "%%%2X", *s++); d += 3; len += 3; + break; default: *d++ = *s++; len++; + break; } } buf[len] = 0; |
