Bug 20907 - Internal error in peicode.h causes program to abort
Summary: Internal error in peicode.h causes program to abort
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.28
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-02 07:26 UTC by Thuan Pham
Modified: 2016-12-05 15:05 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thuan Pham 2016-12-02 07:26:33 UTC
Dear all,
Using AFLFast (https://github.com/mboehme/aflfast), a fork of AFL, we found an input causing different programs (addr2line, strings and size) to abort due to an exception in peicode.h.

The bug was found on Ubuntu 14.04 64-bit & binutils was checked out from https://github.com/bminor/binutils-gdb repository. Its commit is  268ebe95201d2ebdcf68cad9dc67ff6d1e25be9e (Fri Nov 18 14:15:12 2016). We also checked and confirmed the bug using the newest development version of binutils & binutils 2.24. 

To reproduce:

printf "\x00\x00\xff\xff\x00\x00\x4c\x01\x30\x30\x30\x30\x24\x00\x00\x00\x00\x00\x01\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x00\x00\x30\x30\x30\x30\x30\x30\x30\x30" > fd

addr2line -e fd

OR

size fd

OR

strings -d fd

Error message:

BFD (GNU Binutils) 2.27.51.20161128 internal error, aborting at ../../bfd/peicode.h:896 in pe_ILF_build_a_bfd

Best regards,
Thuan
Comment 1 Sourceware Commits 2016-12-05 15:00:17 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=52c4f3bdd5957a31b671a9791f462be5e8eadd85

commit 52c4f3bdd5957a31b671a9791f462be5e8eadd85
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Dec 5 14:59:02 2016 +0000

    Fix abort when running tools on a bogus binary.
    
    	PR binutils/20907
    	* peicode.h (pe_ILF_build_a_bfd): Replace abort with error return.
Comment 2 Nick Clifton 2016-12-05 15:05:31 UTC
Hi Thuan,

  Thanks for reporting this problem.

  I have checked in a patch to replace the internal error with
  an error message, which also has the effect of removing the abort.

Cheers
  Nick