This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] readelf: mask unknown description data bytes.
- From: "Jordan Rupprecht via binutils" <binutils at sourceware dot org>
- To: nickc at redhat dot com
- Cc: echristo at gmail dot com, binutils at sourceware dot org, Jordan Rupprecht <rupprecht at google dot com>
- Date: Wed, 7 Aug 2019 13:48:14 -0700
- Subject: [PATCH] readelf: mask unknown description data bytes.
- Reply-to: Jordan Rupprecht <rupprecht at google dot com>
When printing unknown note types, readelf prints the raw description section byte-by-byte. However, it does not mask appropriately, e.g. it prints the byte 'ba' as 'ffffffba'.
Note the GNU note printer handles this correctly for unknown property types, but the general unknown printer does not.
This was found (and the fix verified) by running readelf -n on a core dump locally, which has a note with the name "LINUX" that is not handled by any of the note printing methods.
---
binutils/ChangeLog | 4 ++++
binutils/readelf.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index b60ae64b27..b6ce3293c8 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@
+2019-08-08 Jordan Rupprecht <rupprecht@google.com>
+
+ * readelf.c (process_note): mask unknown description data bytes.
+
2019-08-08 Alan Modra <amodra@gmail.com>
* readelf.c (get_data): Improve overflow checks.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 3e3e27d19c..3c8a9d418c 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -19115,7 +19115,7 @@ process_note (Elf_Internal_Note * pnote,
printf (_(" description data: "));
for (i = 0; i < pnote->descsz; i++)
- printf ("%02x ", pnote->descdata[i]);
+ printf ("%02x ", pnote->descdata[i] & 0xff);
if (!do_wide)
printf ("\n");
}
--
2.22.0.770.g0f2c4a37fd-goog