nickname is not NULL-terminated

RESOLVED FIXED in 3.3.2

Status

NSS
Libraries
P2
minor
RESOLVED FIXED
16 years ago
16 years ago

People

(Reporter: Jamie Nicolson, Assigned: Jamie Nicolson)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

16 years ago
This code at pkcs11.c:656, in pk11_handleCertObject, doesn't properly
NULL-terminate the copied nickname string.

cert->nickname = (char *)PORT_ArenaAlloc(cert->arena, PORT_Strlen(label)+1);   
       if(cert->nickname == NULL) {
    return CKR_HOST_MEMORY;
}
PORT_Memcpy(cert->nickname, label, PORT_Strlen(label));

This doesn't cause any problems in the code path I witnessed, but it did cause
some confusion during debugging.

Comment 1

16 years ago
That whole thing can be replaced by a PORT_ArenaStrdup call:
    cert->nickname = PORT_ArenaStrdup(cert->arena, label);

Could you take care of that?  Do you think this fix should
also be checked in on the NSS_3_3_BRANCH? 
Assignee: wtc → nicolson
Priority: -- → P2
Target Milestone: --- → 3.4
(Assignee)

Comment 2

16 years ago
Created attachment 52769 [details] [diff] [review]
proposed patch to pkcs11.c
(Assignee)

Comment 3

16 years ago
OK, checked in on the NSS_3_3_BRANCH and the trunk.

/cvsroot/mozilla/security/nss/lib/softoken/pkcs11.c,v  <--  pkcs11.c
new revision: 1.8.2.3; previous revision: 1.8.2.2

/cvsroot/mozilla/security/nss/lib/softoken/pkcs11.c,v  <--  pkcs11.c
new revision: 1.17; previous revision: 1.16
Status: NEW → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → FIXED

Updated

16 years ago
Attachment #52769 - Flags: review+

Comment 4

16 years ago
Looks good.
r=relyea

Comment 5

16 years ago
Changed target milestone to 3.3.2 because the fix is in
3.3.2.
Target Milestone: 3.4 → 3.3.2
You need to log in before you can comment on or make changes to this bug.