Blame SOURCES/0023-Fix-a-minor-coverity-complaint-in-some-apps.patch

4c0d37
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4c0d37
From: Peter Jones <pjones@redhat.com>
4c0d37
Date: Mon, 11 Jun 2018 13:41:05 -0400
4c0d37
Subject: [PATCH] Fix a minor coverity complaint in some apps
4c0d37
4c0d37
Coverity added a new kind of check, and it noticed some minor errors
4c0d37
with some types in two of the apps here, both of the same form:
4c0d37
4c0d37
1. gnu-efi-3.0.6/apps/lfbgrid.c:91: overflow_before_widen: Potentially
4c0d37
overflowing expression "info->VerticalResolution *
4c0d37
info->PixelsPerScanLine" with type "unsigned int" (32 bits, unsigned) is
4c0d37
evaluated using 32-bit arithmetic, and then used in a context that
4c0d37
expects an expression of type "UINTN" (64 bits, unsigned).
4c0d37
4c0d37
1. gnu-efi-3.0.6/apps/bltgrid.c:67: overflow_before_widen: Potentially
4c0d37
overflowing expression "info->VerticalResolution *
4c0d37
info->HorizontalResolution" with type "unsigned int" (32 bits, unsigned)
4c0d37
is evaluated using 32-bit arithmetic, and then used in a context that
4c0d37
expects an expression of type "UINTN" (64 bits, unsigned).
4c0d37
4c0d37
This resolves both issues.
4c0d37
4c0d37
Signed-off-by: Peter Jones <pjones@redhat.com>
4c0d37
---
4c0d37
 apps/bltgrid.c | 3 ++-
4c0d37
 apps/lfbgrid.c | 3 ++-
4c0d37
 2 files changed, 4 insertions(+), 2 deletions(-)
4c0d37
4c0d37
diff --git a/apps/bltgrid.c b/apps/bltgrid.c
4c0d37
index 2adde6a3211..a0eb8c779e4 100644
4c0d37
--- a/apps/bltgrid.c
4c0d37
+++ b/apps/bltgrid.c
4c0d37
@@ -64,7 +64,8 @@ draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
4c0d37
 		if (CompareMem(info, gop->Mode->Info, sizeof (*info)))
4c0d37
 			continue;
4c0d37
 
4c0d37
-		NumPixels = info->VerticalResolution * info->HorizontalResolution;
4c0d37
+		NumPixels = (UINTN)info->VerticalResolution
4c0d37
+                            * (UINTN)info->HorizontalResolution;
4c0d37
 		BufferSize = NumPixels * sizeof(UINT32);
4c0d37
 
4c0d37
 		PixelBuffer = AllocatePool(BufferSize);
4c0d37
diff --git a/apps/lfbgrid.c b/apps/lfbgrid.c
4c0d37
index 53a255afbb9..ac50f4eafa9 100644
4c0d37
--- a/apps/lfbgrid.c
4c0d37
+++ b/apps/lfbgrid.c
4c0d37
@@ -88,7 +88,8 @@ draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
4c0d37
 		if (CompareMem(info, gop->Mode->Info, sizeof (*info)))
4c0d37
 			continue;
4c0d37
 
4c0d37
-		NumPixels = info->VerticalResolution * info->PixelsPerScanLine;
4c0d37
+		NumPixels = (UINTN)info->VerticalResolution
4c0d37
+                            * (UINTN)info->PixelsPerScanLine;
4c0d37
 		BufferSize = NumPixels * sizeof(UINT32);
4c0d37
 		if (BufferSize == gop->Mode->FrameBufferSize) {
4c0d37
 			CopySize = BufferSize;