This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix illegal memory access bug in nm when run on a corrupt binary.


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

commit c12214021dedefcc2320827bcc1751f2d94ca2c6
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Feb 13 17:23:10 2017 +0000

    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.

Diff:
---
 binutils/ChangeLog | 6 ++++++
 binutils/nm.c      | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 294e66c..5baf48e 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,11 @@
 2017-02-13  Nick Clifton  <nickc@redhat.com>
 
+	PR binutils/21150
+	* nm.c (file_symbol): Add test of string length before testing
+	string characters.
+
+2017-02-13  Nick Clifton  <nickc@redhat.com>
+
 	PR binutils/21135
 	* readelf.c (dump_section_as_bytes): Handle the case where
 	uncompress_section_contents returns false.
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')))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]