aboutsummaryrefslogtreecommitdiff
path: root/lib/curl_ntlm_core.c
diff options
context:
space:
mode:
authorDaniel Gustafsson <daniel@yesql.se>2018-04-14 22:42:04 +0200
committerJay Satiro <raysatiro@yahoo.com>2018-04-15 03:00:37 -0400
commit94400f32e9016d2eaea2db583f6e213c36b1eb1d (patch)
treed8c79e652dfa3a9b52b0056cdbe00a66411a502b /lib/curl_ntlm_core.c
parent2b126cd7083ddf1308ebc447cabd1983b16a99fa (diff)
all: Refactor malloc+memset to use calloc
When a zeroed out allocation is required, use calloc() rather than malloc() followed by an explicit memset(). The result will be the same, but using calloc() everywhere increases consistency in the codebase and avoids the risk of subtle bugs when code is injected between malloc and memset by accident. Closes https://github.com/curl/curl/pull/2497
Diffstat (limited to 'lib/curl_ntlm_core.c')
-rw-r--r--lib/curl_ntlm_core.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c
index 72eda34ad..e27cab353 100644
--- a/lib/curl_ntlm_core.c
+++ b/lib/curl_ntlm_core.c
@@ -745,12 +745,10 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
len = NTLM_HMAC_MD5_LEN + NTLMv2_BLOB_LEN;
/* Allocate the response */
- ptr = malloc(len);
+ ptr = calloc(1, len);
if(!ptr)
return CURLE_OUT_OF_MEMORY;
- memset(ptr, 0, len);
-
/* Create the BLOB structure */
snprintf((char *)ptr + NTLM_HMAC_MD5_LEN, NTLMv2_BLOB_LEN,
"%c%c%c%c" /* NTLMv2_BLOB_SIGNATURE */