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.
This commit is contained in:
nelsonb%netscape.com 2003-06-21 07:07:47 +00:00
Родитель 9eb859c9cf
Коммит c40a094aad
1 изменённых файлов: 20 добавлений и 24 удалений

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

@ -917,7 +917,6 @@ loser:
return SECFailure; return SECFailure;
} }
void * void *
CERT_GetGeneralNameByType (CERTGeneralName *genNames, CERT_GetGeneralNameByType (CERTGeneralName *genNames,
CERTGeneralNameType type, PRBool derFormat) CERTGeneralNameType type, PRBool derFormat)
@ -925,38 +924,35 @@ CERT_GetGeneralNameByType (CERTGeneralName *genNames,
CERTGeneralName *current; CERTGeneralName *current;
if (!genNames) if (!genNames)
return (NULL); return NULL;
current = genNames; current = genNames;
do { do {
if (current->type == type) { if (current->type == type) {
switch (type) { switch (type) {
case certDNSName: case certDNSName:
case certEDIPartyName: case certEDIPartyName:
case certIPAddress: case certIPAddress:
case certRegisterID: case certRegisterID:
case certRFC822Name: case certRFC822Name:
case certX400Address: case certX400Address:
case certURI: { case certURI:
return &(current->name.other); return (void *)&current->name.other; /* SECItem * */
}
case certOtherName: { case certOtherName:
return &(current->name.OthName); return (void *)&current->name.OthName; /* OthName * */
break;
} case certDirectoryName:
case certDirectoryName: { return derFormat
if (derFormat) { ? (void *)&current->derDirectoryName /* SECItem * */
return &(current->derDirectoryName); : (void *)&current->name.directoryName; /* CERTName * */
} else{
return &(current->name.directoryName);
}
break;
}
} }
PORT_Assert(0);
return NULL;
} }
current = cert_get_next_general_name(current); current = cert_get_next_general_name(current);
} while (current != genNames); } while (current != genNames);
return (NULL); return NULL;
} }
int int