if (hnLen == current->name.other.len && 0 == memcmp(hn, current->name.other.data, hnLen)) { rv = SECSuccess; goto finish;
if (isIPaddr) { int match = 0; PRIPv6Addr v6Addr; if (current->name.other.len == 4 &&          netAddr.inet.family == PR_AF_INET) { match = !memcmp(&netAddr.inet.ip, current->name.other.data, 4); } else if (current->name.other.len == 16 &&  netAddr.ipv6.family == PR_AF_INET6) { match = !memcmp(&netAddr.ipv6.ip, current->name.other.data, 16); } else if (current->name.other.len == 16 &&  netAddr.inet.family == PR_AF_INET) {   PR_ConvertIPv4AddrToIPv6(netAddr.inet.ip, &v6Addr); match = !memcmp(&v6Addr, current->name.other.data, 16); } else if (current->name.other.len == 4 &&   netAddr.inet.family == PR_AF_INET6) {  PRUint32 ipv4 = (current->name.other.data[0] << 24) | (current->name.other.data[1] << 16) | (current->name.other.data[2] <<  8) | current->name.other.data[3];  PR_ConvertIPv4AddrToIPv6(PR_htonl(ipv4), &v6Addr); match = !memcmp(&netAddr.ipv6.ip, &v6Addr, 16); } if (match) { rv = SECSuccess; goto finish; }
cert_VerifySubjectAltName(CERTCertificate *cert, const char *hn){    PRArenaPool *     arena          = NULL;    CERTGeneralName * nameList       = NULL;    CERTGeneralName * current;    char *            cn;    int               cnBufLen;    int               cnLen;    unsigned int      hnLen;    SECStatus         rv             = SECFailure;    SECItem           subAltName;    char              cnbuf[128];    subAltName.data = NULL;    hnLen    = strlen(hn);    cn       = cnbuf;    cnBufLen = sizeof cnbuf;    rv = CERT_FindCertExtension(cert, SEC_OID_X509_SUBJECT_ALT_NAME, 				&subAltName);    if (rv != SECSuccess) {	if (PORT_GetError() == SEC_ERROR_EXTENSION_NOT_FOUND)	    PORT_SetError(SSL_ERROR_BAD_CERT_DOMAIN);	goto finish;    }    rv = SECFailure;    arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);    if (!arena) 	goto finish;    nameList = current = CERT_DecodeAltNameExtension(arena, &subAltName);    if (!current)    	goto finish;    do {	switch (current->type) {	case certDNSName:	    /* DNS name current->name.other.data is not null terminated.	    ** so much copy it.  Then downshift it.	    */	    cnLen = current->name.other.len;	    if (cnLen + 1 > cnBufLen) {	    	cnBufLen = cnLen + 1;	    	cn = (char *)PORT_ArenaAlloc(arena, cnBufLen);		if (!cn)		    goto finish;	    }	    PORT_Memcpy(cn, current->name.other.data, current->name.other.len);	    cn[cnLen] = 0;	    rv = cert_TestHostName(cn ,hn);	    if (rv == SECSuccess)	    	goto finish;	    break;	case certIPAddress:	    if (hnLen == current->name.other.len &&	        0 == memcmp(hn, current->name.other.data, hnLen)) {		rv = SECSuccess;		goto finish;	    }	    break;	default:	    break;	}	current = cert_get_next_general_name(current);    } while (current != nameList);    PORT_SetError(SSL_ERROR_BAD_CERT_DOMAIN);    rv = SECFailure;finish:    /* Don't free nameList, it's part of the arena. */    if (arena) {	PORT_FreeArena(arena, PR_FALSE);    }    if (subAltName.data) {	SECITEM_FreeItem(&subAltName, PR_FALSE);    }    return rv;}