summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-04-27 12:21:17 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-04-27 12:21:17 +0200
commitbd9ddf85b92d9a8bd882596d1273a8e4d7403869 (patch)
tree6829605edfb031dc96e2a875acf4c272ebc7bd36
parente2b1ccb99beb2c68417c3757aaa7d5d6ba83215f (diff)
downloadcurl-bagder/nss-pk11-null.tar.gz
nss: check for PK11_CreateDigestContext() returning NULLbagder/nss-pk11-null
... to avoid crashes! Reported-by: Hao Wu Fixes #5302
-rw-r--r--lib/vtls/nss.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c
index 3a65a66be..f5a56f4b2 100644
--- a/lib/vtls/nss.c
+++ b/lib/vtls/nss.c
@@ -2374,6 +2374,9 @@ static CURLcode Curl_nss_md5sum(unsigned char *tmp, /* input */
PK11Context *MD5pw = PK11_CreateDigestContext(SEC_OID_MD5);
unsigned int MD5out;
+ if(!MD5pw)
+ return CURLE_OUT_OF_MEMORY;
+
PK11_DigestOp(MD5pw, tmp, curlx_uztoui(tmplen));
PK11_DigestFinal(MD5pw, md5sum, &MD5out, curlx_uztoui(md5len));
PK11_DestroyContext(MD5pw, PR_TRUE);
@@ -2389,6 +2392,9 @@ static CURLcode Curl_nss_sha256sum(const unsigned char *tmp, /* input */
PK11Context *SHA256pw = PK11_CreateDigestContext(SEC_OID_SHA256);
unsigned int SHA256out;
+ if(!SHA256pw)
+ return CURLE_OUT_OF_MEMORY;
+
PK11_DigestOp(SHA256pw, tmp, curlx_uztoui(tmplen));
PK11_DigestFinal(SHA256pw, sha256sum, &SHA256out, curlx_uztoui(sha256len));
PK11_DestroyContext(SHA256pw, PR_TRUE);