[PATCH v3 05/26] readelf: last tag as empty string triggers corrupt string data incorrectly
Matthieu Longo
matthieu.longo@arm.com
Fri May 9 15:12:55 GMT 2025
More information about the Binutils mailing list
Fri May 9 15:12:55 GMT 2025
- Previous message (by thread): [PATCH v3 04/26] bfd/elf-attrs.c: use ASCII character '(0x27) for single quote
- Next message (by thread): [PATCH v3 06/26] bfd: rename parsing methods of object attribute v1 API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
---
binutils/readelf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/binutils/readelf.c b/binutils/readelf.c
index dd1871d8c75..88edf9246cc 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -17779,12 +17779,14 @@ display_tag_value (signed int tag,
else if (tag & 1)
{
/* PR 17531 file: 027-19978-0.004. */
- size_t maxlen = (end - p) - 1;
+ size_t maxlen = end - p;
putchar ('"');
if (maxlen > 0)
{
- print_symbol_name ((int) maxlen, (const char *) p);
+ maxlen -= 1; /* Remove \0 from the character count. */
+ if (maxlen > 0) /* Don't try to print an empty string. */
+ print_symbol_name ((int) maxlen, (const char *) p);
p += strnlen ((char *) p, maxlen) + 1;
}
else
--
2.49.0
- Previous message (by thread): [PATCH v3 04/26] bfd/elf-attrs.c: use ASCII character '(0x27) for single quote
- Next message (by thread): [PATCH v3 06/26] bfd: rename parsing methods of object attribute v1 API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list