From ceba975b15c9754fb0f8f7d4787abc578c1c74fa Mon Sep 17 00:00:00 2001 From: Geoff Lywood Date: Wed, 26 May 2010 17:04:12 -0700 Subject: [PATCH] [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 --- src/util/elf2efi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/elf2efi.c b/src/util/elf2efi.c index 7870bb90..1d73807e 100644 --- a/src/util/elf2efi.c +++ b/src/util/elf2efi.c @@ -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 ); }