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

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