diff options
author | nelsonb%netscape.com <devnull@localhost> | 2004-01-22 23:45:30 +0000 |
---|---|---|
committer | nelsonb%netscape.com <devnull@localhost> | 2004-01-22 23:45:30 +0000 |
commit | e38a746c60c520c44c0244605dea5c2b9b3ebd45 (patch) | |
tree | 169fdac4ac365ab43371b63d79175f95d9cf4b7e /security/nss/lib | |
parent | 91adfb9f606fd68c83f36ee109cf2375f9910222 (diff) | |
download | nss-hg-e38a746c60c520c44c0244605dea5c2b9b3ebd45.tar.gz |
When a name attribute's value exceeds the maximum allowed length, display
a truncated version of it, followed by ellipsis. Bug 220855. r=wtc
Diffstat (limited to 'security/nss/lib')
-rw-r--r-- | security/nss/lib/certdb/alg1485.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/security/nss/lib/certdb/alg1485.c b/security/nss/lib/certdb/alg1485.c index 916f09cbe..b95cec96a 100644 --- a/security/nss/lib/certdb/alg1485.c +++ b/security/nss/lib/certdb/alg1485.c @@ -695,11 +695,19 @@ AppendAVA(stringBuf *bufp, CERTAVA *ava) } /* Check value length */ - if (avaValue->len > maxLen) { - if (unknownTag) PR_smprintf_free(unknownTag); - SECITEM_FreeItem(avaValue, PR_TRUE); - PORT_SetError(SEC_ERROR_INVALID_AVA); - return SECFailure; + if (avaValue->len > maxLen + 3) { /* must be room for "..." */ + /* avaValue is a UTF8 string, freshly allocated and returned to us + ** by CERT_DecodeAVAValue just above, so we can modify it here. + ** See if we're in the middle of a multi-byte UTF8 character. + */ + while (((avaValue->data[maxLen] & 0xc0) == 0x80) && maxLen > 0) { + maxLen--; + } + /* add elipsis to signify truncation. */ + avaValue->data[maxLen++] = '.'; + avaValue->data[maxLen++] = '.'; + avaValue->data[maxLen++] = '.'; + avaValue->len = maxLen; } len = PORT_Strlen(tagName); |