Closed Bug 596631 Opened 15 years ago Closed 4 years ago

non-printable character throws exception in org.mozilla.jss.asn1.PrintableString.charToByte()

Categories

(JSS Graveyard :: Library, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: io, Assigned: glenbeasley)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; it; rv:1.9.1.12) Gecko/20100825 SeaMonkey/2.0.7 Build Identifier: jss4.jar I had a problem with a commercial program using nss/jss which was throwing the following exception: org.mozilla.jss.asn1.InvalidBERException: is not a valid character for a PrintableString at org.mozilla.jss.asn1.CharacterString$Template.decode(CharacterString.java:181) ... By digging into the code of jss, I found the class org.mozilla.jss.asn1.PrintableString which contains the following comment in the method byteToChar(): if( (bytes[b] & 0x80) != 0 || !isPrintable[bytes[b]] ) { /* fix for bug 359010 - don't throw, just skip * throw new CharConversionException(bytes[b]+ " is not "+ * "a valid character for a PrintableString"); */ } else { chars[c] = (char) bytes[b]; } The above fix works, but it's missing in the code of the following method, charToByte(): if( (chars[c] & 0xff80) != 0 || !isPrintable[chars[c]] ) { throw new CharConversionException(chars[c]+ " is not "+ "a valid character for a PrintableString"); } bytes[b] = (byte) (chars[c] & 0x7f); As far as I can understand, even in this case the "throw" clause should be commented. Indeed with this fix, the program i was having problem now works fine: it seems that program (or some nss library) was passing as parameter to the above method an array (chars[c]) where the last byte is a 0, and it should be ignored and not throw an exception. Reproducible: Always
JSS development has moved from the Mozilla community to the Dogtag PKI community. Please re-file this bug at https://github.com/dogtagpki/jss if it is still relevant. Thank you!
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.