From cad15b9f92812ea4cdec6b65b7e2a83bdc007eb3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 27 Apr 2020 12:21:17 +0200 Subject: nss: check for PK11_CreateDigestContext() returning NULL ... to avoid crashes! Reported-by: Hao Wu Fixes #5302 Closes #5303 --- lib/vtls/nss.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') 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); -- cgit v1.2.3