diff options
author | Nick Clifton <nickc@redhat.com> | 2017-02-13 17:23:10 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2017-02-13 17:23:10 +0000 |
commit | c12214021dedefcc2320827bcc1751f2d94ca2c6 (patch) | |
tree | 1bf1e0e05a1bbd06db94f92790b6ae135ce7cceb /binutils/nm.c | |
parent | 1835f746a7c7fff70a2cc03a051b14fdc6b3f73f (diff) | |
download | gdb-c12214021dedefcc2320827bcc1751f2d94ca2c6.zip gdb-c12214021dedefcc2320827bcc1751f2d94ca2c6.tar.gz gdb-c12214021dedefcc2320827bcc1751f2d94ca2c6.tar.bz2 |
Fix illegal memory access bug in nm when run on a corrupt binary.
PR binutils/21150
* nm.c (file_symbol): Add test of string length before testing
string characters.
Diffstat (limited to 'binutils/nm.c')
-rw-r--r-- | binutils/nm.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/binutils/nm.c b/binutils/nm.c index fcbab41..7ddcc8a 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -685,7 +685,8 @@ size_forward1 (const void *P_x, const void *P_y) #define file_symbol(s, sn, snl) \ (((s)->flags & BSF_FILE) != 0 \ - || ((sn)[(snl) - 2] == '.' \ + || ((snl) > 2 \ + && (sn)[(snl) - 2] == '.' \ && ((sn)[(snl) - 1] == 'o' \ || (sn)[(snl) - 1] == 'a'))) |