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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2010-03-25 13:46:06 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100325134606-bl6liuok2w9l7snv
Tags: 3.12.6-0ubuntu1
* New upstream release 3.12.6 RTM (NSS_3_12_6_RTM)
  - fixes CVE-2009-3555 aka US-CERT VU#120541
* Adjust patches to changed upstream code base
  - update debian/patches/38_kbsd.patch
  - update debian/patches/38_mips64_build.patch
  - update debian/patches/85_security_load.patch
* Remove patches that are merged upstream
  - delete debian/patches/91_nonexec_stack.patch
  - update debian/patches/series
* Bump nspr dependency to 4.8
  - update debian/control
* Add new symbols for 3.12.6
  - update debian/libnss3-1d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
618
618
 * Return all of the CAs that are "trusted" for SSL.
619
619
 */
620
620
CERTDistNames *
 
621
CERT_DupDistNames(CERTDistNames *orig)
 
622
{
 
623
    PRArenaPool *arena;
 
624
    CERTDistNames *names;
 
625
    int i;
 
626
    SECStatus rv;
 
627
    
 
628
    /* allocate an arena to use */
 
629
    arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
 
630
    if (arena == NULL) {
 
631
        PORT_SetError(SEC_ERROR_NO_MEMORY);
 
632
        return(NULL);
 
633
    }
 
634
    
 
635
    /* allocate the header structure */
 
636
    names = (CERTDistNames *)PORT_ArenaAlloc(arena, sizeof(CERTDistNames));
 
637
    if (names == NULL) {
 
638
        goto loser;
 
639
    }
 
640
 
 
641
    /* initialize the header struct */
 
642
    names->arena = arena;
 
643
    names->head = NULL;
 
644
    names->nnames = orig->nnames;
 
645
    names->names = NULL;
 
646
    
 
647
    /* construct the array from the list */
 
648
    if (orig->nnames) {
 
649
        names->names = (SECItem*)PORT_ArenaNewArray(arena, SECItem,
 
650
                                                    orig->nnames);
 
651
        if (names->names == NULL) {
 
652
            goto loser;
 
653
        }
 
654
        for (i = 0; i < orig->nnames; i++) {
 
655
            rv = SECITEM_CopyItem(arena, &names->names[i], &orig->names[i]);
 
656
            if (rv != SECSuccess) {
 
657
                goto loser;
 
658
            }
 
659
        }
 
660
    }
 
661
    return(names);
 
662
    
 
663
loser:
 
664
    PORT_FreeArena(arena, PR_FALSE);
 
665
    return(NULL);
 
666
}
 
667
 
 
668
CERTDistNames *
621
669
CERT_GetSSLCACerts(CERTCertDBHandle *handle)
622
670
{
623
671
    PRArenaPool *arena;
679
727
}
680
728
 
681
729
CERTDistNames *
 
730
CERT_DistNamesFromCertList(CERTCertList *certList)
 
731
{
 
732
    CERTDistNames *   dnames = NULL;
 
733
    PRArenaPool *     arena;
 
734
    CERTCertListNode *node = NULL;
 
735
    SECItem *         names = NULL;
 
736
    int               listLen = 0, i = 0;
 
737
 
 
738
    if (certList == NULL) {
 
739
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
 
740
        return NULL;
 
741
    }
 
742
 
 
743
    node = CERT_LIST_HEAD(certList);
 
744
    while ( ! CERT_LIST_END(node, certList) ) {
 
745
        listLen += 1;
 
746
        node = CERT_LIST_NEXT(node);
 
747
    }
 
748
    
 
749
    arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
 
750
    if (arena == NULL) goto loser;
 
751
    dnames = PORT_ArenaZNew(arena, CERTDistNames);
 
752
    if (dnames == NULL) goto loser;
 
753
 
 
754
    dnames->arena = arena;
 
755
    dnames->nnames = listLen;
 
756
    dnames->names = names = PORT_ArenaZNewArray(arena, SECItem, listLen);
 
757
    if (names == NULL) goto loser;
 
758
 
 
759
    node = CERT_LIST_HEAD(certList);
 
760
    while ( ! CERT_LIST_END(node, certList) ) {
 
761
        CERTCertificate *cert = node->cert;
 
762
        SECStatus rv = SECITEM_CopyItem(arena, &names[i++], &cert->derSubject);
 
763
        if (rv == SECFailure) {
 
764
            goto loser;
 
765
        }
 
766
        node = CERT_LIST_NEXT(node);
 
767
    }
 
768
    return dnames;
 
769
loser:
 
770
    if (arena) {
 
771
        PORT_FreeArena(arena, PR_FALSE);
 
772
    }
 
773
    return NULL;
 
774
}
 
775
 
 
776
CERTDistNames *
682
777
CERT_DistNamesFromNicknames(CERTCertDBHandle *handle, char **nicknames,
683
778
                           int nnames)
684
779
{