From 12db51d20823a5e3b9e5f8a2ea73156fe1cbfc28 Mon Sep 17 00:00:00 2001 From: Eric van Gyzen Date: Tue, 6 Apr 2021 09:42:20 -0500 Subject: [PATCH] uefisign: handle empty sections loader.efi has an empty set_Xfic section. Handle it correctly. ``` Sections: Idx Name Size VMA LMA File off Algn [...] 3 set_Xcom 00000168 00000000000d4000 00000000000d4000 000d0e00 2**2 CONTENTS, ALLOC, LOAD, DATA 4 set_Xfic 00000000 00000000000d4168 00000000000d4168 00000000 2**2 ALLOC, LOAD, DATA 5 .sdata 00000448 00000000000d5000 00000000000d5000 000d1000 2**2 CONTENTS, ALLOC, LOAD, DATA [...] ``` Reviewed by: trasz, dab Reported by: andy.y.liu@dell.com Tested by: andy.y.liu@dell.com MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D29606 --- usr.sbin/uefisign/pe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/uefisign/pe.c b/usr.sbin/uefisign/pe.c index 9f010e5d8a46..6459321441d8 100644 --- a/usr.sbin/uefisign/pe.c +++ b/usr.sbin/uefisign/pe.c @@ -244,7 +244,8 @@ parse_section_table(struct executable *x, off_t off, int number_of_sections) x->x_nsections = number_of_sections; for (i = 0; i < number_of_sections; i++) { - if (psh->psh_pointer_to_raw_data < x->x_headers_len) + if (psh->psh_size_of_raw_data > 0 && + psh->psh_pointer_to_raw_data < x->x_headers_len) errx(1, "section points inside the headers"); range_check(x, psh->psh_pointer_to_raw_data,