]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl_easy_escape: limit output string length to 3 * max input
authorDaniel Stenberg <daniel@haxx.se>
Mon, 9 Nov 2020 15:24:13 +0000 (16:24 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 9 Nov 2020 22:01:06 +0000 (23:01 +0100)
... instead of the limiting it to just the max input size. As every
input byte can be expanded to 3 output bytes, this could limit the input
string to 2.66 MB instead of the intended 8 MB.

Reported-by: Marc Schlatter
Closes #6192

lib/escape.c

index 1ec698aa6d649e98abfb936437b4a663d3d9bb2a..683b6fc4a65e49556f0c32ebc791f6355ce33f9e 100644 (file)
@@ -86,7 +86,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
   if(inlength < 0)
     return NULL;
 
-  Curl_dyn_init(&d, CURL_MAX_INPUT_LENGTH);
+  Curl_dyn_init(&d, CURL_MAX_INPUT_LENGTH * 3);
 
   length = (inlength?(size_t)inlength:strlen(string));
   if(!length)