]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
url: reject too long input when parsing credentials
authorDaniel Stenberg <daniel@haxx.se>
Tue, 12 May 2020 22:52:34 +0000 (00:52 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 13 May 2020 06:02:42 +0000 (08:02 +0200)
Since input passed to libcurl with CURLOPT_USERPWD and
CURLOPT_PROXYUSERPWD circumvents the regular string length check we have
in Curl_setstropt(), the input length limit is enforced in
Curl_parse_login_details too, separately.

Reported-by: Thomas Bouzerar
Closes #5383

lib/url.c

index d0e60d2ea8d29943738e79f8a56a2df7a506032d..ce94bac05c6319fda1c8c5d9cb5cce1aaa64d8bc 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -2586,6 +2586,12 @@ CURLcode Curl_parse_login_details(const char *login, const size_t len,
   size_t plen;
   size_t olen;
 
+  /* the input length check is because this is called directcly from setopt
+     and isn't going through the regular string length check */
+  size_t llen = strlen(login);
+  if(llen > CURL_MAX_INPUT_LENGTH)
+    return CURLE_BAD_FUNCTION_ARGUMENT;
+
   /* Attempt to find the password separator */
   if(passwdp) {
     psep = strchr(login, ':');