SecurityPkg/HashInstanceLibSha1: Added Allocation check for codeql (#163)

## Description

A small change to check if we're able to successfully allocate. This
allows us to pass CodeQL checks.

- [ ] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

Tested to make sure physical platforms could boot. Also confirmed codeql
tests pass as well.

## Integration Instructions

N/A
This commit is contained in:
kenlautner 2023-08-08 12:23:05 -07:00 коммит произвёл GitHub
Родитель fad8d8f534
Коммит 82b89c105d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 7 добавлений и 1 удалений

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

@ -56,7 +56,13 @@ Sha1HashInit (
CtxSize = Sha1GetContextSize ();
Sha1Ctx = AllocatePool (CtxSize);
ASSERT (Sha1Ctx != NULL);
// MU_CHANGE [BEGIN] - CodeQL change
if (Sha1Ctx == NULL) {
ASSERT (Sha1Ctx != NULL);
return EFI_OUT_OF_RESOURCES;
}
// MU_CHANGE [END] - CodeQL change
Sha1Init (Sha1Ctx);