зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
9eb859c9cf
Коммит
c40a094aad
|
@ -917,7 +917,6 @@ loser:
|
|||
return SECFailure;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
CERT_GetGeneralNameByType (CERTGeneralName *genNames,
|
||||
CERTGeneralNameType type, PRBool derFormat)
|
||||
|
@ -925,38 +924,35 @@ CERT_GetGeneralNameByType (CERTGeneralName *genNames,
|
|||
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 *)¤t->name.other; /* SECItem * */
|
||||
|
||||
case certOtherName:
|
||||
return (void *)¤t->name.OthName; /* OthName * */
|
||||
|
||||
case certDirectoryName:
|
||||
return derFormat
|
||||
? (void *)¤t->derDirectoryName /* SECItem * */
|
||||
: (void *)¤t->name.directoryName; /* CERTName * */
|
||||
}
|
||||
PORT_Assert(0);
|
||||
return NULL;
|
||||
}
|
||||
current = cert_get_next_general_name(current);
|
||||
} while (current != genNames);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Загрузка…
Ссылка в новой задаче