Fix bugs experienced with oddly constructed general names.

Partially fixes bug 204555. r=wtc a=sspitzer
This commit is contained in:
nelsonb%netscape.com 2003-05-24 06:27:35 +00:00
Родитель b6c9f837db
Коммит 3f9a09add1
2 изменённых файлов: 28 добавлений и 53 удалений

Просмотреть файл

@ -605,6 +605,7 @@ cert_DecodeNameConstraintSubTree(PRArenaPool *arena,
CERTNameConstraint *next = NULL; CERTNameConstraint *next = NULL;
int i = 0; int i = 0;
PORT_Assert(arena);
while (subTree[i] != NULL) { while (subTree[i] != NULL) {
current = cert_DecodeNameConstraint(arena, subTree[i]); current = cert_DecodeNameConstraint(arena, subTree[i]);
if (current == NULL) { if (current == NULL) {
@ -621,14 +622,6 @@ cert_DecodeNameConstraintSubTree(PRArenaPool *arena,
first->l.prev = &(current->l); first->l.prev = &(current->l);
return first; return first;
loser: loser:
if (first) {
current = first;
do {
next = cert_get_next_name_constraint(current);
PORT_Free(current);
current = next;
}while (current != first);
}
return NULL; return NULL;
} }
@ -842,7 +835,7 @@ CERT_AddNameConstraint(CERTNameConstraint *list,
SECStatus SECStatus
CERT_GetNameConstriantByType (CERTNameConstraint *constraints, CERT_GetNameConstraintByType (CERTNameConstraint *constraints,
CERTGeneralNameType type, CERTGeneralNameType type,
CERTNameConstraint **returnList, CERTNameConstraint **returnList,
PRArenaPool *arena) PRArenaPool *arena)
@ -1268,7 +1261,7 @@ CERT_CompareNameSpace(CERTCertificate *cert,
} }
do { do {
if (constraints->excluded != NULL) { if (constraints->excluded != NULL) {
rv = CERT_GetNameConstriantByType(constraints->excluded, currentName->type, rv = CERT_GetNameConstraintByType(constraints->excluded, currentName->type,
&matchingConstraints, arena); &matchingConstraints, arena);
if (rv != SECSuccess) { if (rv != SECSuccess) {
goto loser; goto loser;
@ -1282,7 +1275,7 @@ CERT_CompareNameSpace(CERTCertificate *cert,
} }
} }
if (constraints->permited != NULL) { if (constraints->permited != NULL) {
rv = CERT_GetNameConstriantByType(constraints->permited, currentName->type, rv = CERT_GetNameConstraintByType(constraints->permited, currentName->type,
&matchingConstraints, arena); &matchingConstraints, arena);
if (rv != SECSuccess) { if (rv != SECSuccess) {
goto loser; goto loser;

Просмотреть файл

@ -67,8 +67,8 @@ CountArray(void **array)
return count; return count;
} }
static void static void **
**AddToArray(PRArenaPool *arena, void **array, void *element) AddToArray(PRArenaPool *arena, void **array, void *element)
{ {
unsigned count; unsigned count;
void **ap; void **ap;
@ -96,35 +96,6 @@ static void
return array; return array;
} }
#if 0
static void
**RemoveFromArray(void **array, void *element)
{
unsigned count;
void **ap;
int slot;
/* Look for element */
ap = array;
if (ap) {
count = 1; /* count the null at the end */
slot = -1;
for (; *ap; ap++, count++) {
if (*ap == element) {
/* Found it */
slot = ap - array;
}
}
if (slot >= 0) {
/* Found it. Squish array down */
PORT_Memmove((void*) (array + slot), (void*) (array + slot + 1),
(count - slot - 1) * sizeof(void*));
/* Don't bother reallocing the memory */
}
}
return array;
}
#endif /* 0 */
SECOidTag SECOidTag
CERT_GetAVATag(CERTAVA *ava) CERT_GetAVATag(CERTAVA *ava)
@ -461,27 +432,38 @@ SECStatus
CERT_CopyName(PRArenaPool *arena, CERTName *to, CERTName *from) CERT_CopyName(PRArenaPool *arena, CERTName *to, CERTName *from)
{ {
CERTRDN **rdns, *frdn, *trdn; CERTRDN **rdns, *frdn, *trdn;
SECStatus rv; SECStatus rv = SECSuccess;
if (!to || !from) if (!to || !from) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return SECFailure; return SECFailure;
}
CERT_DestroyName(to); CERT_DestroyName(to);
to->arena = arena; to->arena = arena;
/* Copy each rdn from from */ /* Copy each rdn from from */
rdns = from->rdns; rdns = from->rdns;
while ((frdn = *rdns++) != 0) { if (rdns) {
if (rdns[0] == NULL) {
rv = CERT_AddRDN(to, NULL);
return rv;
}
while ((frdn = *rdns++) != NULL) {
trdn = CERT_CreateRDN(arena, 0); trdn = CERT_CreateRDN(arena, 0);
if ( trdn == NULL ) { if (!trdn) {
return(SECFailure); rv = SECFailure;
break;
} }
rv = CERT_CopyRDN(arena, trdn, frdn); rv = CERT_CopyRDN(arena, trdn, frdn);
if (rv) return rv; if (rv != SECSuccess)
break;
rv = CERT_AddRDN(to, trdn); rv = CERT_AddRDN(to, trdn);
if (rv) return rv; if (rv != SECSuccess)
break;
} }
return SECSuccess; }
return rv;
} }
/************************************************************************/ /************************************************************************/