]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Curl_is_ASCII_name: handle a NULL argument
authorDaniel Stenberg <daniel@haxx.se>
Thu, 27 Feb 2020 10:06:14 +0000 (11:06 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 27 Feb 2020 12:55:29 +0000 (13:55 +0100)
Make the function tolerate a NULL pointer input to avoid dereferencing
that pointer.

Follow-up to efce3ea5a85126d
Detected by OSS-Fuzz
Reviewed-By: Steve Holme
Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20907
Fixes #4985
Closes #4986

lib/smtp.c
lib/url.c

index a87e6126ad452194b409a28bfdf019e7679a77ea..79499e6d40fde4a73f125d8ca92f8d24dd606814 100644 (file)
@@ -1773,8 +1773,6 @@ static CURLcode smtp_parse_address(struct connectdata *conn, const char *fqma,
        and send the host name using UTF-8 rather than as 7-bit ACE (which is
        our preference) */
   }
-  else
-    host->name = NULL;
 
   /* Extract the local address from the mailbox */
   *address = dup;
index 85cdd53368b6869bc0b628d949d2bacceebbb175..47fc66aedda6e80120c7e38093c60267b5897a9f 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1438,8 +1438,12 @@ void Curl_verboseconnect(struct connectdata *conn)
  */
 bool Curl_is_ASCII_name(const char *hostname)
 {
+  /* get an UNSIGNED local version of the pointer */
   const unsigned char *ch = (const unsigned char *)hostname;
 
+  if(!hostname) /* bad input, consider it ASCII! */
+    return TRUE;
+
   while(*ch) {
     if(*ch++ & 0x80)
       return FALSE;