Skip to content

Commit

Permalink
Added additional CodeQL fixes for 202302
Browse files Browse the repository at this point in the history
  • Loading branch information
kenlautner committed Jul 13, 2023
1 parent 5152c2a commit 92e488d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
9 changes: 8 additions & 1 deletion CryptoPkg/Test/UnitTest/Library/BaseCryptLib/X509Tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,14 @@ TestVerifyX509 (
Status = X509GetIssuerName (mTestCert, sizeof (mTestCert), NULL, &SubjectSize);
UT_ASSERT_TRUE (!Status);
Subject = AllocatePool (SubjectSize);
Status = X509GetIssuerName (mTestCert, sizeof (mTestCert), Subject, &SubjectSize);
// MU_CHANGE [BEGIN] - CodeQL change
if (Subject == NULL) {
ASSERT (Subject != NULL);
return UNIT_TEST_ERROR_TEST_FAILED;
}

// MU_CHANGE [END] - CodeQL change
Status = X509GetIssuerName (mTestCert, sizeof (mTestCert), Subject, &SubjectSize);
UT_ASSERT_TRUE (Status);
FreePool (Subject);

Expand Down
29 changes: 26 additions & 3 deletions UefiCpuPkg/CpuMpPei/CpuMpPei.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,25 @@ InitializeMpExceptionStackSwitchHandlers (
// }
// MU_CHANGE END

MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL);
// MU_CHANGE [BEGIN] - CodeQL change
Status = MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL);
if (EFI_ERROR (Status)) {
ASSERT (NumberOfProcessors != NULL);
DEBUG ((DEBUG_ERROR, "%a - Failed to get number of processors. Status = %r\n", __FUNCTION__, Status));
return;
}

// MU_CHANGE [END] - CodeQL change

SwitchStackData = AllocatePages (EFI_SIZE_TO_PAGES (NumberOfProcessors * sizeof (EXCEPTION_STACK_SWITCH_CONTEXT)));
ASSERT (SwitchStackData != NULL);
// MU_CHANGE [BEGIN] - CodeQL change
if (SwitchStackData == NULL) {
ASSERT (SwitchStackData != NULL);
DEBUG ((DEBUG_ERROR, "%a - Failed to allocate Switch Stack pages.\n", __FUNCTION__));
return;
}

// MU_CHANGE [END] - CodeQL change
ZeroMem (SwitchStackData, NumberOfProcessors * sizeof (EXCEPTION_STACK_SWITCH_CONTEXT));
for (Index = 0; Index < NumberOfProcessors; ++Index) {
//
Expand Down Expand Up @@ -573,7 +589,14 @@ InitializeMpExceptionStackSwitchHandlers (

if (BufferSize != 0) {
Buffer = AllocatePages (EFI_SIZE_TO_PAGES (BufferSize));
ASSERT (Buffer != NULL);
// MU_CHANGE [BEGIN] - CodeQL change
if (Buffer == NULL) {
ASSERT (Buffer != NULL);
DEBUG ((DEBUG_ERROR, "%a - Failed to allocate Buffer pages.\n", __FUNCTION__));
return;
}

// MU_CHANGE [END] - CodeQL change
BufferSize = 0;
for (Index = 0; Index < NumberOfProcessors; ++Index) {
if (SwitchStackData[Index].Status == EFI_BUFFER_TOO_SMALL) {
Expand Down

0 comments on commit 92e488d

Please sign in to comment.