aboutsummaryrefslogtreecommitdiff
path: root/lib/vtls
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 16:25:59 +0200
commitcad15b9f92812ea4cdec6b65b7e2a83bdc007eb3 (patch)
tree62a0740e28a5ec9a1b1b6e3dbb0098fe841b7e23 /lib/vtls
parente2b1ccb99beb2c68417c3757aaa7d5d6ba83215f (diff)
nss: check for PK11_CreateDigestContext() returning NULL
... to avoid crashes! Reported-by: Hao Wu Fixes #5302 Closes #5303
Diffstat (limited to 'lib/vtls')
-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..16ec409e9 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_NOT_BUILT_IN;
+
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_NOT_BUILT_IN;
+
PK11_DigestOp(SHA256pw, tmp, curlx_uztoui(tmplen));
PK11_DigestFinal(SHA256pw, sha256sum, &SHA256out, curlx_uztoui(sha256len));
PK11_DestroyContext(SHA256pw, PR_TRUE);