summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-11-04 16:42:21 +0100
committerDaniel Stenberg <daniel@haxx.se>2017-11-04 16:42:21 +0100
commitc5df98a67fc1fa58ed5e5a16f1e595cefde021db (patch)
tree1511fd0726d254d03d53e7c841144e9d50afb475
parent90abb74ff0e3134d8647722cee36b1815c14143d (diff)
downloadcurl-c5df98a67fc1fa58ed5e5a16f1e595cefde021db.tar.gz
ntlm: avoid malloc(0) for zero length passwordsbagder/zero-length-ntlm-passwd
It triggers an assert() when built with memdebug since malloc(0) may return NULL *or* a valid pointer. Detected by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4054 Assisted-by: Max Dymond
-rw-r--r--lib/curl_ntlm_core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c
index 5154949e6..1309bf0d9 100644
--- a/lib/curl_ntlm_core.c
+++ b/lib/curl_ntlm_core.c
@@ -557,7 +557,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
unsigned char *ntbuffer /* 21 bytes */)
{
size_t len = strlen(password);
- unsigned char *pw = malloc(len * 2);
+ unsigned char *pw = len ? malloc(len * 2) : strdup("");
CURLcode result;
if(!pw)
return CURLE_OUT_OF_MEMORY;