aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-03-06 17:21:04 +0000
committerNick Clifton <nickc@redhat.com>2017-03-06 17:21:04 +0000
commit79a964dca572024447adf92e50959dc88aa4f27a (patch)
tree09e99b075264be366a07519a05062b33f40d9fc0
parent73f07bffaf8d423295a38dde51dfe6ec7b273280 (diff)
downloadgdb-79a964dca572024447adf92e50959dc88aa4f27a.zip
gdb-79a964dca572024447adf92e50959dc88aa4f27a.tar.gz
gdb-79a964dca572024447adf92e50959dc88aa4f27a.tar.bz2
Fix reading numeric values from GNU BUILD NOTEs.
* readelf.c (print_gnu_build_attribute_name): Read byte values from the name string as unsigned bytes. (process_notes_at): Use memcpy to copy an unterminated name string.
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/readelf.c6
2 files changed, 11 insertions, 2 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 4e3f78a..6a1c269 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2017-03-06 Nick Clifton <nickc@redhat.com>
+
+ * readelf.c (print_gnu_build_attribute_name): Read byte values
+ from the name string as unsigned bytes.
+ (process_notes_at): Use memcpy to copy an unterminated name
+ string.
+
2017-03-06 Sam Thursfield <sam.thursfield@codethink.co.uk>
* configure.ac (AC_CHECK_DECLS): Add asprintf.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 3bae045..9ed8d41 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -16768,7 +16768,9 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
while (bytes --)
{
- val |= ((* name ++) << shift);
+ unsigned long byte = (* name ++) & 0xff;
+
+ val |= byte << shift;
shift += 8;
}
@@ -17042,7 +17044,7 @@ process_notes_at (FILE * file,
break;
}
- strncpy (temp, inote.namedata, inote.namesz);
+ memcpy (temp, inote.namedata, inote.namesz);
temp[inote.namesz] = 0;
/* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */