The default bug view has changed. See this FAQ.

CERT_OpenCertDB() leaks filename

RESOLVED FIXED in 3.1

Status

NSS
Libraries
P3
normal
RESOLVED FIXED
17 years ago
17 years ago

People

(Reporter: John G. Myers, Assigned: Ian McGreer)

Tracking

unspecified

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

17 years ago
CERT_OpenCertDB() leaks the filename returned from the filename callback.
(Reporter)

Updated

17 years ago
Status: NEW → ASSIGNED

Comment 1

17 years ago
Ian, is there a duplicate for this bug?
Assignee: jgmyers → mcgreer
Status: ASSIGNED → NEW
Target Milestone: --- → 3.1

Updated

17 years ago
QA Contact: wtc → sonmi

Comment 2

17 years ago
Created attachment 15921 [details] [diff] [review]
Proposed patch.

Comment 3

17 years ago
Created attachment 15933 [details] [diff] [review]
Revised patch. certDBFilenameCallback needs to strdup the filename string.

Comment 4

17 years ago
This bug is similar to, but not a duplicate of, bug #39476.

Comments on the revised patch (id=15933):
1. SEC_OpenPermCertDB (called by CERT_OpenCertDB) should
   free certdbname before it returns.
2. certDBFilenameCallback needs to duplicate the filename
   string so that its return value can be freed by
   SEC_OpenPermCertDB.

Please review the patch.  Thanks.
(Assignee)

Comment 5

17 years ago
this looks fine to me.  Thanks Wan-Teh.

Comment 6

17 years ago
I checked in the fix on the tip.
/cvsroot/mozilla/security/nss/lib/certdb/pcertdb.c, revision 1.4
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED
(Reporter)

Comment 7

17 years ago
test_cdb_name_cb() in mailnews/mime/src/mimefilt.cpp needs to be changed to 
return the cert filename in malloced memory.

Same thing for CertDBFilenameCallback() in security/nss/lib/certdb/pcertdb.c
Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Comment 8

17 years ago
mailnews/mime/src/mimefilt.cpp is not part of NSS.

My checkin already included the change you suggested
for certDBFilenameCallback() in
security/nss/lib/certdb/pcertdb.c.
Status: REOPENED → RESOLVED
Last Resolved: 17 years ago17 years ago
Resolution: --- → FIXED

Comment 9

17 years ago
test_kdb_name_cb() in mailnews/mime/src/mimefilt.cpp
also needs the same change.
Do any server products that use NSS also need similar changes?
(Reporter)

Comment 11

17 years ago
Possibly.  This needs to be mentioned in the release notes.

Comment 12

17 years ago
Are CERT_OpenCertDB() and SECKEY_OpenKeyDB() typically
only called once in an application session?   If so, I'd
like to propose that we back out the PORT_Free() calls
from these two functions so that we do not break existing
filename callback functions that do not return their results
in malloc'ed memory.

On the other hand, since NSS 3.1 is likely to be the first
3.x release that most products will pick up, it might be
sufficient to mention this change in the release notes.
(Reporter)

Comment 13

17 years ago
SECKEY_OpenKeyDB() already had a PORT_Free() call for the failure case, so any 
existing filename callback function for that function which did not return its 
results in malloc'ed memory is already broken.

All of the CERT_OpenCertDB() calls from adminsdk use functions which return 
malloc'ed memory.

Comment 14

17 years ago
> SECKEY_OpenKeyDB() already had a PORT_Free() call for
> the failure case, so any existing filename callback function
> for that function which did not return its results in
> malloc'ed memory is already broken.

Is it possible that the failure case code has never been exercised?
(Reporter)

Comment 15

17 years ago
No, because the server I work on ran into it extremely early.
You need to log in before you can comment on or make changes to this bug.