]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
escape: allow curl_easy_escape to generate 3*input length output
authorDaniel Stenberg <daniel@haxx.se>
Thu, 1 Aug 2024 14:42:58 +0000 (16:42 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 1 Aug 2024 21:03:21 +0000 (23:03 +0200)
Instead of capping it to the 3 * CURL_MAX_INPUT_LENGTH. To allow users
to URL encode larger chunks of data.

Closes #14339

lib/escape.c

index 1633c2da2b8d033f16654c0d5db8dd32aabac389..9b6edb44335e4548b62573ad0526b9510b9db3df 100644 (file)
@@ -63,12 +63,12 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
   if(!string || (inlength < 0))
     return NULL;
 
-  Curl_dyn_init(&d, CURL_MAX_INPUT_LENGTH * 3);
-
   length = (inlength?(size_t)inlength:strlen(string));
   if(!length)
     return strdup("");
 
+  Curl_dyn_init(&d, length * 3 + 1);
+
   while(length--) {
     /* treat the characters unsigned */
     unsigned char in = (unsigned char)*string++;