Closed Bug 125728 Opened 23 years ago Closed 23 years ago

Implement correct utf8 pkcs11 string truncation.

Categories

(NSS :: Libraries, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ssaux, Assigned: rrelyea)

References

Details

Attachments

(1 file, 2 obsolete files)

pkcs11 string are currently lopped off at 32 or 64 bytes without regards to the
utf8 character boundary.

I discussed this with Bob Relyea and he agreed that NSS could include the
functionality in softoken/pkcs11.c::pk11_setStringName().

I have a patch.
Attached patch enhance PK11_setStringName() (obsolete) — Splinter Review
Tested with: all ascii.
entering escaped unicode in pipnss.properties so that:
utf8 boundary results in a string of exactly 32 bytes.
utf8 boundary results in a string of exactly 31 bytes, in which case the the
32nd byte becomes a blank.
Attachment #69671 - Attachment is obsolete: true
Comments on the patch:

'And' masking is more common and generally easier to read than 'or' masking:
 (byte & 0xc0) == 0x80
rather than
 (byte | 0x3f) == 0xbf.

A shift is even easier to read, though less efficient:
 (byte >> 6) == 0x02.

The and and or are equal efficiency.

bob
Do you want a new patch?
Assigned the bug to Bob.

Yes, Stephane, please attach a new patch.
Assignee: wtc → relyea
Priority: -- → P1
Target Milestone: --- → 3.4
Attachment #69675 - Attachment is obsolete: true
Blocks: 90956
Stephan's fix is checked in.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: