Closed Bug 340217 Opened 20 years ago Closed 20 years ago

Coverity 543, leak after OOM in CMMF_POPODecKeyChallContDecryptChallenge

Categories

(NSS :: Libraries, defect, P2)

3.11.1
defect

Tracking

(Not tracked)

RESOLVED FIXED
3.11.3

People

(Reporter: nelson, Assigned: nelson)

Details

(Keywords: coverity, memory-leak)

Attachments

(1 file, 2 obsolete files)

In CMMF_POPODecKeyChallContDecryptChallenge, if the allocation of decryptedRand succeeds, but the subsequent allocation of decryptedRand->data fails, the function goes to loser, and returns without freeing decryptedRand, hence leaking it.
Assignee: nobody → alexei.volkov.bugs
Priority: -- → P2
Target Milestone: --- → 3.11.3
This function is unbelievably broken. One cannot tell what it was supposed to do, but one can be sure it doesn't do that, whatever that was. Please write a patch that replaces the entire body of this function with something like this: { /* This unused function had many flaws, and has been deimplemented. */ PORT_SetError(PR_NOT_IMPLEMENTED_ERROR); return SECFailure; }
This URL shows one big problem I see in this function. http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/security/nss/lib/crmf/challcli.c&rev=1.5&mark=141,161,167-168#140 Bob, you and I have worked on this code before. It surely didn't seem as obviously broken to me that last time I worked on it as it does now. Please review this code (as it is) and tell me if I'm missing something and it's really OK.
Assignee: alexei.volkov.bugs → nelson
Status: NEW → ASSIGNED
Attachment #224835 - Flags: superreview?(rrelyea)
Attachment #224835 - Flags: review?(alexei.volkov.bugs)
Comment on attachment 224835 [details] [diff] [review] patch to eliminate code in this bad function r=alexei.volkov
Attachment #224835 - Flags: review?(alexei.volkov.bugs) → review+
Attached patch try to make it work as intended (obsolete) — — Splinter Review
I wasn't really happy with the prospect of eliminating this function, so I attempted to figure out what it was really trying to do, and reimplemented much of it to do that. In reviewing this, please make sure that it seems to make sense. :)
Attachment #224835 - Attachment is obsolete: true
Attachment #225165 - Flags: review?(alexei.volkov.bugs)
Attachment #224835 - Flags: superreview?(rrelyea)
This patch is the same as the previous one, except that I set different error codes.
Attachment #225165 - Attachment is obsolete: true
Attachment #225166 - Flags: review?(alexei.volkov.bugs)
Attachment #225165 - Flags: review?(alexei.volkov.bugs)
Comment on attachment 225166 [details] [diff] [review] patch v2, don't use OCSP error code for CMMF r=alexei.volkov
Attachment #225166 - Flags: review?(alexei.volkov.bugs) → review+
Coverity bug 340217. Fix leak, crash, and failure to set error codes in CMMF_POPODecKeyChallContDecryptChallenge. r=alexei.volkov Checking in challcli.c; new revision: 1.6; previous revision: 1.5 Checking in challcli.c; new revision: 1.5.28.1; previous revision: 1.5 Resolved / fixed
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: