Closed Bug 1411500 Opened 7 years ago Closed 7 years ago

Coverity issue in cryptohi_unittest.cc

Categories

(NSS :: Test, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: franziskus, Assigned: ueno)

References

(Blocks 1 open bug)

Details

(Keywords: coverity)

Attachments

(1 file)

There's an unchecked return value in the test code from bug 1400844. *** CID 1420176: Error handling issues (CHECKED_RETURN) /gtests/cryptohi_gtest/cryptohi_unittest.cc: 70 in nss_test::SignParamsTestF::CreatePssParams(SECKEYRSAPSSParamsStr *, SECOidTag, SECOidTag)() 64 void CreatePssParams(SECKEYRSAPSSParams *params, SECOidTag hashAlgTag, 65 SECOidTag maskHashAlgTag) { 66 CreatePssParams(params, hashAlgTag); 67 68 SECAlgorithmID maskHashAlg; 69 PORT_Memset(&maskHashAlg, 0, sizeof(maskHashAlg)); >>> CID 1420176: Error handling issues (CHECKED_RETURN) >>> Calling "SECOID_SetAlgorithmID_Util" without checking return value (as is done elsewhere 46 out of 52 times). 70 SECOID_SetAlgorithmID(arena_.get(), &maskHashAlg, maskHashAlgTag, NULL); 71 72 SECItem *maskHashAlgItem = 73 SEC_ASN1EncodeItem(arena_.get(), NULL, &maskHashAlg, 74 SEC_ASN1_GET(SECOID_AlgorithmIDTemplate)); 75
Flags: needinfo?(dueno)
Thanks for filing this; it should be fixed with the attached patch. (Also added a missing error check on SECITEM_AllocItem(), copied from ecl_unittest.cc.)
Flags: needinfo?(dueno)
Attachment #8921799 - Flags: review?(franziskuskiefer)
Assignee: nobody → dueno
Priority: -- → P1
Comment on attachment 8921799 [details] [diff] [review] check-return-value.patch Review of attachment 8921799 [details] [diff] [review]: ----------------------------------------------------------------- ::: gtests/cryptohi_gtest/cryptohi_unittest.cc @@ +37,4 @@ > SECOidData *oidData; > oidData = SECOID_FindOIDByTag(SEC_OID_CURVE25519); > ASSERT_NE(nullptr, oidData); > + if (SECITEM_AllocItem(NULL, &ecParams, (2 + oidData->oid.len)) == nullptr) { You could do ASSERT_NE(nulltrp, SECITEM_AllocItem(..)) << "Couldn't allocate memory for OID."; as well
Attachment #8921799 - Flags: review?(franziskuskiefer) → review+
Thank you for the review. Landed as: https://hg.mozilla.org/projects/nss/rev/300a20af3d82
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.34
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: