PORT_Strcpy(tmpBuf+len, (char *)avaValue->data);
PORT_Strncpy(tmpBuf+len, (char *)avaValue->data, avaValue->len + 1);
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;    PRBool hexValue = PR_FALSE;    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 = CERT_GetOidString(&ava->type);	if (!tagName)	    return SECFailure;    }    maxLen = n2k->maxLen;#ifdef NSS_STRICT_RFC_2253_VALUES_ONLY    if (!unknownTag)#endif    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;	}	hexValue = PR_TRUE;    }    /* Check value length */    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);    if (len+1 > sizeof(tmpBuf)) {	if (unknownTag) PR_smprintf_free(unknownTag);	SECITEM_FreeItem(avaValue, PR_TRUE);	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 - don't quote hex strings */    if (hexValue) {        /* appent avaValue to tmpBuf */	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, 		    		     (char *)avaValue->data, avaValue->len);    SECITEM_FreeItem(avaValue, PR_TRUE);    if (rv) return SECFailure;        rv = AppendStr(bufp, tmpBuf);    return rv;}