Skip to content

Commit f5fad0e

Browse files
committed
_do_sha256_sum(): Fix missing error check.
Coverity scan has correctly spotted that Sha256Init() and related functions may return an error. Honestly I don't know /how/ any of these can return an error, since the context is the only part that should allocate, but it's defined that way. Signed-off-by: Peter Jones <pjones@redhat.com>
1 parent d316ba8 commit f5fad0e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pe.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ _do_sha256_sum(void *addr, UINTN size, UINT8 *digest)
5050
if (sha256ctx == NULL)
5151
return EFI_OUT_OF_RESOURCES;
5252

53-
Sha256Init(sha256ctx);
54-
Sha256Update(sha256ctx, addr, size);
55-
Sha256Final(sha256ctx, digest);
53+
if (!Sha256Init(sha256ctx))
54+
return EFI_OUT_OF_RESOURCES;
55+
56+
if (!Sha256Update(sha256ctx, addr, size))
57+
return EFI_OUT_OF_RESOURCES;
58+
59+
if (!Sha256Final(sha256ctx, digest))
60+
return EFI_OUT_OF_RESOURCES;
5661

5762
FreePool(sha256ctx);
5863
return EFI_SUCCESS;

0 commit comments

Comments
 (0)