Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleanup CERT_GetGeneralNameByType so that it detects when it has
encountered a general name of a type that it doesn't recognize, and
so that it properly casts the return value to be of the right type.
  • Loading branch information
nelsonb%netscape.com committed Jun 21, 2003
1 parent 500f290 commit be599e7
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions security/nss/lib/certdb/genname.c
Expand Up @@ -917,46 +917,42 @@ CERT_GetNameConstraintByType (CERTNameConstraint *constraints,
return SECFailure;
}


void *
CERT_GetGeneralNameByType (CERTGeneralName *genNames,
CERTGeneralNameType type, PRBool derFormat)
{
CERTGeneralName *current;

if (!genNames)
return (NULL);
return NULL;
current = genNames;

do {
if (current->type == type) {
switch (type) {
case certDNSName:
case certEDIPartyName:
case certIPAddress:
case certRegisterID:
case certRFC822Name:
case certX400Address:
case certURI: {
return &(current->name.other);
}
case certOtherName: {
return &(current->name.OthName);
break;
}
case certDirectoryName: {
if (derFormat) {
return &(current->derDirectoryName);
} else{
return &(current->name.directoryName);
}
break;
}
case certDNSName:
case certEDIPartyName:
case certIPAddress:
case certRegisterID:
case certRFC822Name:
case certX400Address:
case certURI:
return (void *)&current->name.other; /* SECItem * */

case certOtherName:
return (void *)&current->name.OthName; /* OthName * */

case certDirectoryName:
return derFormat
? (void *)&current->derDirectoryName /* SECItem * */
: (void *)&current->name.directoryName; /* CERTName * */
}
PORT_Assert(0);
return NULL;
}
current = cert_get_next_general_name(current);
} while (current != genNames);
return (NULL);
return NULL;
}

int
Expand Down

0 comments on commit be599e7

Please sign in to comment.