From d3a1198bfc671530ed77ad2b81b0ae4582f9378e Mon Sep 17 00:00:00 2001
From: Lans Zhang <jia.zhang@windriver.com>
Date: Sun, 24 Apr 2016 15:56:38 +0800
Subject: [PATCH] chainloader: Don't check empty section in file like .bss

Upstream-Status: Pending

Because this kind of section always has a zeroed PointerToRawData denoting
the offset to file and a valid VirtualSize denoting the real size in the
memory.

Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
---
 grub-core/loader/efi/chainloader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
index 2d8edc0..0e84100 100644
--- a/grub-core/loader/efi/chainloader.c
+++ b/grub-core/loader/efi/chainloader.c
@@ -526,7 +526,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size,
 	 }
 
 	if (section->virtual_address < context->header_size
-	    || section->raw_data_offset < context->header_size)
+	    || (section->raw_data_offset && section->raw_data_offset < context->header_size))
 	  {
 	    grub_printf("Section is inside image headers\n");
 	    status = GRUB_ERR_BAD_FILE_TYPE;
-- 
1.9.1

