summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-02-27 11:06:14 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-02-27 13:55:29 +0100
commit1d1e9e8ad7a5f35818dc7072e6fbe8a76a93e018 (patch)
treeeaf64f71ffb1e9a3bb72065df2568173c1fa75b8
parent9faa0d2b4c0007ef5063eee818c4ac1db5d7de47 (diff)
downloadcurl-1d1e9e8ad7a5f35818dc7072e6fbe8a76a93e018.tar.gz
Curl_is_ASCII_name: handle a NULL argument
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
-rw-r--r--lib/smtp.c2
-rw-r--r--lib/url.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index a87e6126a..79499e6d4 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -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;
diff --git a/lib/url.c b/lib/url.c
index 85cdd5336..47fc66aed 100644
--- 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;