sftkdb_DeleteSecmodDB leaks block if fgets fails after continue

RESOLVED FIXED

Status

NSS
Libraries
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: timeless, Assigned: timeless)

Tracking

({coverity, memory-leak})

trunk
x86
Windows 7
coverity, memory-leak

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment, 1 obsolete attachment)

1.40 KB, patch
timeless
: review+
Nelson Bolyard (seldom reads bugmail)
: review+
Details | Diff | Splinter Review
(Assignee)

Description

7 years ago
fwiw, colapses is misspelled

533 sftkdb_DeleteSecmodDB(SDBType dbType, const char *appName, 
542     char *block = NULL;
588     while (fgets(line, sizeof(line), fd) != NULL) { 
612             block = sftkdb_DupCat(block,line);
613             continue;

the code here assumes that after continue fgets will succeed again. this seems unlikely.
(Assignee)

Comment 1

7 years ago
Created attachment 498300 [details] [diff] [review]
proposal
Assignee: nobody → timeless
Status: NEW → ASSIGNED
Attachment #498300 - Flags: review?(nelson)
Comment on attachment 498300 [details] [diff] [review]
proposal

r=nelson
Attachment #498300 - Flags: review?(nelson) → review+

Comment 3

7 years ago
Comment on attachment 498300 [details] [diff] [review]
proposal

Thanks for the patch.  You just need to call
    PORT_Free(block);

PORT_Free does nothing if the input is NULL, and it's not
necessary to set 'block' to NULL because we're returning
from the function immediately.
(Assignee)

Comment 4

7 years ago
Created attachment 501647 [details] [diff] [review]
less thinking
Attachment #498300 - Attachment is obsolete: true
Attachment #501647 - Flags: review+
Bug 619813: sftkdb_DeleteSecmodDB leaks block if fgets fails after continue
Patch contributed by Timeless <timeless@mozdev.org>, r=nelson

Checking in softoken/sftkmod.c; new revision: 1.8; previous revision: 1.7
Status: ASSIGNED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.