1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

Curl_is_ASCII_name: handle a NULL argument

Make the function tolerate a NULL pointer input to avoid dereferencing
that pointer.

Follow-up to efce3ea5a8
Detected by OSS-Fuzz
Reviewed-By: Steve Holme
Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20907
Fixes #4985
Closes #4986
This commit is contained in:
Daniel Stenberg 2020-02-27 11:06:14 +01:00
parent 9faa0d2b4c
commit 1d1e9e8ad7
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 4 additions and 2 deletions

View 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;

View File

@ -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;