From c12214021dedefcc2320827bcc1751f2d94ca2c6 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 13 Feb 2017 17:23:10 +0000 Subject: [PATCH] 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. --- binutils/ChangeLog | 6 ++++++ binutils/nm.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 294e66ce44b..5baf48efa21 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2017-02-13 Nick Clifton + + PR binutils/21150 + * nm.c (file_symbol): Add test of string length before testing + string characters. + 2017-02-13 Nick Clifton PR binutils/21135 diff --git a/binutils/nm.c b/binutils/nm.c index fcbab416f78..7ddcc8a113d 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'))) -- 2.30.2