git: f3629ca2f555 - stable/13 - uefisign: handle empty sections
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Mar 2022 21:57:14 UTC
The branch stable/13 has been updated by vangyzen:
URL: https://cgit.FreeBSD.org/src/commit/?id=f3629ca2f5557a5e2897dda74c6e362600916103
commit f3629ca2f5557a5e2897dda74c6e362600916103
Author: Eric van Gyzen <vangyzen@FreeBSD.org>
AuthorDate: 2021-04-06 14:42:20 +0000
Commit: Eric van Gyzen <vangyzen@FreeBSD.org>
CommitDate: 2022-03-02 21:56:30 +0000
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
(cherry picked from commit 12db51d20823a5e3b9e5f8a2ea73156fe1cbfc28)
---
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,