Parcourir la source

[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>
tags/v1.20.1
Geoff Lywood il y a 14 ans
Parent
révision
ceba975b15
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. 3
    2
      src/util/elf2efi.c

+ 3
- 2
src/util/elf2efi.c Voir le fichier

@@ -247,8 +247,9 @@ static bfd * open_input_bfd ( const char *filename ) {
247 247
 	/* The call to bfd_check_format() must be present, otherwise
248 248
 	 * we get a segfault from later BFD calls.
249 249
 	 */
250
-	if ( bfd_check_format ( bfd, bfd_object ) < 0 ) {
251
-		eprintf ( "%s is not an object file\n", filename );
250
+	if ( ! bfd_check_format ( bfd, bfd_object ) ) {
251
+		eprintf ( "%s is not an object file: ", filename );
252
+		bfd_perror ( NULL );
252 253
 		exit ( 1 );
253 254
 	}
254 255
 

Chargement…
Annuler
Enregistrer