rv = CERT_RFC1485_EscapeAndQuote(tmpBuf+len, sizeof(tmpBuf)-len,
if (hexValue) {  if (avaValue->len + len + 1 > sizeof tmpBuf) { PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); rv = SECFailure; } else { PORT_Strcpy(tmpBuf+len, (char *)avaValue->data); rv = SECSuccess; } } else rv = CERT_RFC1485_EscapeAndQuote(tmpBuf+len, sizeof(tmpBuf)-len,
AppendAVA(stringBuf *bufp, CERTAVA *ava){    const struct NameToKind *n2k = name2kinds;    const char *tagName;    unsigned len, maxLen;    int tag;    SECStatus rv;    SECItem *avaValue = NULL;    char *unknownTag = NULL;    char tmpBuf[384];    tag = CERT_GetAVATag(ava);    while (n2k->kind != tag && n2k->kind != SEC_OID_UNKNOWN) {        ++n2k;    }    if (n2k->kind != SEC_OID_UNKNOWN) {        tagName = n2k->name;    } else {	/* handle unknown attribute types per RFC 2253 */	tagName = unknownTag = get_oid_string(&ava->type);    }    maxLen = n2k->maxLen;    avaValue = CERT_DecodeAVAValue(&ava->value);    if(!avaValue) {	/* the attribute value is not recognized, get the hex value */	avaValue = get_hex_string(&ava->value);	if(!avaValue) {	    if (unknownTag) PR_smprintf_free(unknownTag);	    return SECFailure;	}    }    /* Check value length */    if (avaValue->len > maxLen) {	if (unknownTag) PR_smprintf_free(unknownTag);	PORT_SetError(SEC_ERROR_INVALID_AVA);	return SECFailure;    }    len = PORT_Strlen(tagName);    if (len+1 > sizeof(tmpBuf)) {	if (unknownTag) PR_smprintf_free(unknownTag);	PORT_SetError(SEC_ERROR_OUTPUT_LEN);	return SECFailure;    }    PORT_Memcpy(tmpBuf, tagName, len);    if (unknownTag) PR_smprintf_free(unknownTag);    tmpBuf[len++] = '=';        /* escape and quote as necessary */    rv = CERT_RFC1485_EscapeAndQuote(tmpBuf+len, sizeof(tmpBuf)-len, 		    		     (char *)avaValue->data, avaValue->len);    SECITEM_FreeItem(avaValue, PR_TRUE);    if (rv) return SECFailure;        rv = AppendStr(bufp, tmpBuf);    return rv;}