Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[efi] Verify object format support in elf2efi.c
Currently, if you attempt to build 64-bit EFI binaries on a 32-bit
system without a suitable cross-compiling version of libbfd, the iPXE
build will die with a segmentation fault in elf2efi64.

Fix by properly handling the return value from bfd_check_format().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
Geoff Lywood authored and mcb30 committed May 27, 2010
1 parent 620b98e commit ceba975
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/util/elf2efi.c
Expand Up @@ -247,8 +247,9 @@ static bfd * open_input_bfd ( const char *filename ) {
/* The call to bfd_check_format() must be present, otherwise
* we get a segfault from later BFD calls.
*/
if ( bfd_check_format ( bfd, bfd_object ) < 0 ) {
eprintf ( "%s is not an object file\n", filename );
if ( ! bfd_check_format ( bfd, bfd_object ) ) {
eprintf ( "%s is not an object file: ", filename );
bfd_perror ( NULL );
exit ( 1 );
}

Expand Down

0 comments on commit ceba975

Please sign in to comment.