diff options
author | Daniel Stenberg <daniel@haxx.se> | 2019-04-25 17:15:12 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2019-04-25 17:28:44 +0200 |
commit | f9ff558056f6659920db7a9225a92a1328b66103 (patch) | |
tree | 8280b3e5ce2d782658b3940cd4fe1b2f9715c7dd /lib/urlapi.c | |
parent | e7d3f65ab95a358b7ec305659f12b9ffe4dc510e (diff) | |
download | curl-f9ff558056f6659920db7a9225a92a1328b66103.tar.gz |
CURL_MAX_INPUT_LENGTH: largest acceptable string input size
This limits all accepted input strings passed to libcurl to be less than
CURL_MAX_INPUT_LENGTH (1000000) bytes, for these API calls:
curl_easy_setopt() and curl_url_set().
The 1000000 number is arbitrary picked and is meant to detect mistakes
or abuse, not to limit actual practical use cases. By limiting the
acceptable string lengths we also reduce the risk of integer overflows
all over.
NOTE_ This does not apply to `CURLOPT_POSTFIELDS`.
Diffstat (limited to 'lib/urlapi.c')
-rw-r--r-- | lib/urlapi.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/urlapi.c b/lib/urlapi.c index 0eb06d24d..57f82cac5 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -642,6 +642,10 @@ static CURLUcode seturl(const char *url, CURLU *u, unsigned int flags) ************************************************************/ /* allocate scratch area */ urllen = strlen(url); + if(urllen > CURL_MAX_INPUT_LENGTH) + /* excessive input length */ + return CURLUE_MALFORMED_INPUT; + path = u->scratch = malloc(urllen * 2 + 2); if(!path) return CURLUE_OUT_OF_MEMORY; @@ -1279,6 +1283,10 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, const char *newp = part; size_t nalloc = strlen(part); + if(nalloc > CURL_MAX_INPUT_LENGTH) + /* excessive input length */ + return CURLUE_MALFORMED_INPUT; + if(urlencode) { const unsigned char *i; char *o; |