2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-11-25 19:08:35 +00:00

[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>
This commit is contained in:
Geoff Lywood 2010-05-26 17:04:12 -07:00 committed by Michael Brown
parent 620b98ee4b
commit ceba975b15

View File

@ -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 );
}