Only accept up to SIZE_MAX/16 input bytes. To avoid overflows, mistakes
and abuse.
Follow-up to
9bfc7f923479235b2fdf0e
Reported-by: Daniel Santos
Closes #20086
constrained by its type, the returned string may not be altered.
If *length* is set to 0 (zero), curl_easy_escape(3) uses strlen() on the input
-*string* to find out the size. This function does not accept input strings
-longer than **CURL_MAX_INPUT_LENGTH** (8 MB).
+*string* to find out the size.
You must curl_free(3) the returned string when you are done with it.
if(!length)
return curlx_strdup("");
+ if(length > SIZE_MAX/16)
+ return NULL;
+
curlx_dyn_init(&d, length * 3 + 1);
while(length--) {