Code clean-up to eliminate potential "dereferenced pointer" warning.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Qin Long <qin.long@intel.com> 
Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16468 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Qin Long 2014-12-03 07:40:32 +00:00 committed by qlong
parent 2aa580be65
commit 7e0699c06e
1 changed files with 20 additions and 17 deletions

View File

@ -860,6 +860,7 @@ IsCertHashFoundInDatabase (
HashAlg = HASHALG_MAX; HashAlg = HASHALG_MAX;
ASSERT (RevocationTime != NULL); ASSERT (RevocationTime != NULL);
ASSERT (DbxList != NULL);
while ((DbxSize > 0) && (SignatureListSize >= DbxList->SignatureListSize)) { while ((DbxSize > 0) && (SignatureListSize >= DbxList->SignatureListSize)) {
// //
@ -1132,15 +1133,16 @@ PassTimestampCheck (
// //
DbtDataSize = 0; DbtDataSize = 0;
Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE2, &gEfiImageSecurityDatabaseGuid, NULL, &DbtDataSize, NULL); Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE2, &gEfiImageSecurityDatabaseGuid, NULL, &DbtDataSize, NULL);
if (Status == EFI_BUFFER_TOO_SMALL) { if (Status != EFI_BUFFER_TOO_SMALL) {
DbtData = (UINT8 *) AllocateZeroPool (DbtDataSize); goto Done;
if (DbtData == NULL) { }
goto Done; DbtData = (UINT8 *) AllocateZeroPool (DbtDataSize);
} if (DbtData == NULL) {
Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE2, &gEfiImageSecurityDatabaseGuid, NULL, &DbtDataSize, (VOID *) DbtData); goto Done;
if (EFI_ERROR (Status)) { }
goto Done; Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE2, &gEfiImageSecurityDatabaseGuid, NULL, &DbtDataSize, (VOID *) DbtData);
} if (EFI_ERROR (Status)) {
goto Done;
} }
CertList = (EFI_SIGNATURE_LIST *) DbtData; CertList = (EFI_SIGNATURE_LIST *) DbtData;
@ -1229,14 +1231,15 @@ IsForbiddenByDbx (
// //
DataSize = 0; DataSize = 0;
Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid, NULL, &DataSize, NULL); Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid, NULL, &DataSize, NULL);
if (Status == EFI_BUFFER_TOO_SMALL) { if (Status != EFI_BUFFER_TOO_SMALL) {
Data = (UINT8 *) AllocateZeroPool (DataSize); return IsForbidden;
if (Data == NULL) {
return IsForbidden;
}
Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid, NULL, &DataSize, (VOID *) Data);
} }
Data = (UINT8 *) AllocateZeroPool (DataSize);
if (Data == NULL) {
return IsForbidden;
}
Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid, NULL, &DataSize, (VOID *) Data);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return IsForbidden; return IsForbidden;
} }
@ -1254,7 +1257,7 @@ IsForbiddenByDbx (
// UINT8 Certn[]; // UINT8 Certn[];
// //
Pkcs7GetSigners (AuthData, AuthDataSize, &CertBuffer, &BufferLength, &TrustedCert, &TrustedCertLength); Pkcs7GetSigners (AuthData, AuthDataSize, &CertBuffer, &BufferLength, &TrustedCert, &TrustedCertLength);
if (BufferLength == 0) { if ((BufferLength == 0) || (CertBuffer == NULL)) {
IsForbidden = TRUE; IsForbidden = TRUE;
goto Done; goto Done;
} }