git: 5deb35002545 - main - uefisign: fix SizeOfHeaders sanity check.

Warner Losh imp at FreeBSD.org
Thu Jun 3 21:22:30 UTC 2021


The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=5deb35002545ca5081cc90795fec68bcea30f75d

commit 5deb35002545ca5081cc90795fec68bcea30f75d
Author:     Kenneth Camann <kjcamann at gmail.com>
AuthorDate: 2021-01-03 02:11:42 +0000
Commit:     Warner Losh <imp at FreeBSD.org>
CommitDate: 2021-06-03 21:22:14 +0000

    uefisign: fix SizeOfHeaders sanity check.
    
    This check was too aggressive: it is fine if SizeOfHeaders is exactly
    equal to the size of the DOS stub + PE header + section table. Despite
    being wrong this code typically worked for most EFI binaries because
    SizeOfHeaders is rounded up to a multiple of FileAlignment, which is
    often large (e.g., 512 bytes for the FreeBSD loader) so most binaries
    made it through.
    
    Reviewed by:    imp@
    Sponsored by:   Netflix
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/445
---
 usr.sbin/uefisign/pe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/uefisign/pe.c b/usr.sbin/uefisign/pe.c
index 6459321441d8..09b5edd56ab7 100644
--- a/usr.sbin/uefisign/pe.c
+++ b/usr.sbin/uefisign/pe.c
@@ -232,7 +232,7 @@ parse_section_table(struct executable *x, off_t off, int number_of_sections)
 	range_check(x, off, sizeof(*psh) * number_of_sections,
 	    "section table");
 
-	if (x->x_headers_len <= off + sizeof(*psh) * number_of_sections)
+	if (x->x_headers_len < off + sizeof(*psh) * number_of_sections)
 		errx(1, "section table outside of headers");
 
 	psh = (const struct pe_section_header *)(x->x_buf + off);


More information about the dev-commits-src-all mailing list