瀏覽代碼

[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 14 年之前
父節點
當前提交
ceba975b15
共有 1 個檔案被更改,包括 3 行新增2 行删除
  1. 3
    2
      src/util/elf2efi.c

+ 3
- 2
src/util/elf2efi.c 查看文件

@@ -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
 

Loading…
取消
儲存