]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Ensure EFI binaries comply with Authenticode requirements
authorMichael Brown <mcb30@ipxe.org>
Mon, 25 Feb 2013 17:22:01 +0000 (17:22 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 25 Feb 2013 17:22:01 +0000 (17:22 +0000)
Authenticode requires that the size of the raw file must equal the
size of the OptionalHeader.SizeOfHeaders plus the sum of all sections'
SizeOfRawData.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/util/elf2efi.c

index 007453e24acff041cd39627cdbb7dd2aeb90f83c..b28c7ef33e05f46f2aacaeb9d5cb5923512f0ecd 100644 (file)
@@ -614,8 +614,11 @@ static void write_pe_file ( struct pe_header *pe_header,
        struct pe_section *section;
        unsigned long fpos = 0;
 
+       /* Align length of headers */
+       fpos = pe_header->nt.OptionalHeader.SizeOfHeaders =
+               efi_file_align ( pe_header->nt.OptionalHeader.SizeOfHeaders );
+
        /* Assign raw data pointers */
-       fpos = efi_file_align ( pe_header->nt.OptionalHeader.SizeOfHeaders );
        for ( section = pe_sections ; section ; section = section->next ) {
                if ( section->hdr.SizeOfRawData ) {
                        section->hdr.PointerToRawData = fpos;