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
This commit is contained in:
Eric van Gyzen 2021-04-06 09:42:20 -05:00
parent 066a576c5f
commit 12db51d208

View File

@ -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,