~ubuntu-branches/ubuntu/raring/nss/raring-security

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/certdb/certdb.c

Tags: 3.12.8-0ubuntu0.10.10.1
* New upstream release v3.12.8 (NSS_3_12_8_RTM)
  - Fix browser wildcard certificate validation issue
  - Update root certs
  - Fix SSL deadlocks
* Refresh patches:
  - update debian/patches/38_kbsd.patch
  - update debian/patches/97_SSL_RENEGOTIATE_TRANSITIONAL.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
/*
40
40
 * Certificate handling code
41
41
 *
42
 
 * $Id: certdb.c,v 1.104 2010/04/25 00:44:55 nelson%bolyard.com Exp $
 
42
 * $Id: certdb.c,v 1.104.2.2 2010/09/02 00:52:02 wtc%google.com Exp $
43
43
 */
44
44
 
45
45
#include "nssilock.h"
1415
1415
    return;
1416
1416
}
1417
1417
 
 
1418
static PRBool
 
1419
cert_IsIPAddr(const char *hn)
 
1420
{
 
1421
    PRBool            isIPaddr       = PR_FALSE;
 
1422
    PRNetAddr         netAddr;
 
1423
    isIPaddr = (PR_SUCCESS == PR_StringToNetAddr(hn, &netAddr));
 
1424
    return isIPaddr;
 
1425
}
 
1426
 
1418
1427
/*
1419
1428
** Add a domain name to the list of names that the user has explicitly
1420
1429
** allowed (despite cert name mismatches) for use with a server cert.
1880
1889
 
1881
1890
    cn = CERT_GetCommonName(&cert->subject);
1882
1891
    if ( cn ) {
1883
 
        rv = cert_TestHostName(cn, hn);
 
1892
        PRBool isIPaddr = cert_IsIPAddr(hn);
 
1893
        if (isIPaddr) {
 
1894
            if (PORT_Strcasecmp(hn, cn) == 0) {
 
1895
                rv =  SECSuccess;
 
1896
            } else {
 
1897
                PORT_SetError(SSL_ERROR_BAD_CERT_DOMAIN);
 
1898
                rv = SECFailure;
 
1899
            }
 
1900
        } else {
 
1901
            rv = cert_TestHostName(cn, hn);
 
1902
        }
1884
1903
        PORT_Free(cn);
1885
1904
    } else 
1886
1905
        PORT_SetError(SSL_ERROR_BAD_CERT_DOMAIN);
2110
2129
        PORT_Free(nickname);
2111
2130
    }
2112
2131
 
2113
 
    nickname = "";
 
2132
    nickname = NULL;
2114
2133
    
2115
2134
done:
2116
2135
    if ( firstname ) {