Blame SOURCES/0010-shim-Extend-invalid-reloc-size-warning-message.patch

d1e1c8
From 956717e2b375d7c7f0faafec8f12a7692708eb9a Mon Sep 17 00:00:00 2001
d1e1c8
From: Paul Menzel <pmenzel@molgen.mpg.de>
d1e1c8
Date: Wed, 23 May 2018 12:32:37 +0200
d1e1c8
Subject: [PATCH 10/62] shim: Extend invalid reloc size warning message
d1e1c8
d1e1c8
Knowing the value of the reloc directory size is helpful for debugging,
d1e1c8
cf. issue #131 [1],
d1e1c8
d1e1c8
[1]: https://github.com/rhboot/shim/issues/131
d1e1c8
d1e1c8
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
d1e1c8
Upstream-commit-id: dd3230d07f3
d1e1c8
---
d1e1c8
 shim.c | 10 ++++++++--
d1e1c8
 1 file changed, 8 insertions(+), 2 deletions(-)
d1e1c8
d1e1c8
diff --git a/shim.c b/shim.c
d1e1c8
index ff0817009cd..05fc65005d1 100644
d1e1c8
--- a/shim.c
d1e1c8
+++ b/shim.c
d1e1c8
@@ -280,8 +280,14 @@ static EFI_STATUS relocate_coff (PE_COFF_LOADER_IMAGE_CONTEXT *context,
d1e1c8
 	while (RelocBase < RelocBaseEnd) {
d1e1c8
 		Reloc = (UINT16 *) ((char *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));
d1e1c8
 
d1e1c8
-		if ((RelocBase->SizeOfBlock == 0) || (RelocBase->SizeOfBlock > context->RelocDir->Size)) {
d1e1c8
-			perror(L"Reloc %d block size %d is invalid\n", n, RelocBase->SizeOfBlock);
d1e1c8
+		if (RelocBase->SizeOfBlock == 0) {
d1e1c8
+			perror(L"Reloc %d block size 0 is invalid\n", n);
d1e1c8
+			return EFI_UNSUPPORTED;
d1e1c8
+		} else if (RelocBase->SizeOfBlock > context->RelocDir->Size) {
d1e1c8
+			perror(L"Reloc %d block size %d greater than reloc dir"
d1e1c8
+					"size %d, which is invalid\n", n,
d1e1c8
+					RelocBase->SizeOfBlock,
d1e1c8
+					context->RelocDir->Size);
d1e1c8
 			return EFI_UNSUPPORTED;
d1e1c8
 		}
d1e1c8
 
d1e1c8
-- 
d1e1c8
2.26.2
d1e1c8