]> granicus.if.org Git - libevent/commitdiff
Fix evhttp_uriencode() regression.
authorZonr Chang <zonr.net@gmail.com>
Wed, 24 Aug 2016 09:16:32 +0000 (17:16 +0800)
committerAzat Khuzhin <a3at.mail@gmail.com>
Fri, 26 Aug 2016 22:24:11 +0000 (01:24 +0300)
http_uriencode_test() (in test/regress_http.c) has been failed after
72afe4c as "hello\0world" is encoded to "hello" instead of
"hello%00world". This is because of a misplaced overflow check which
causes the non-negative "size" specified in parameter being ignored in
within-bound URI.

Fixes: #392
http.c

diff --git a/http.c b/http.c
index 6fee8702305c0c78f4de6f945a8cc5dc260a69a4..b9f909e4ac6dd9d62a4b3033f29beae9f1e7b410 100644 (file)
--- a/http.c
+++ b/http.c
@@ -3079,7 +3079,7 @@ evhttp_uriencode(const char *uri, ev_ssize_t len, int space_as_plus)
        }
 
 
-       if (len >= 0 && uri + len < uri) {
+       if (len >= 0) {
                if (uri + len < uri) {
                        return (NULL);
                }