binutils/backport-PR28048-heap-buffer-overflow-on-readelf-Ww.patch

26 lines
843 B
Diff

From 4ff0bb2df5e0ce6dc30b8dd2a0d4174649d0dcfe Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Fri, 2 Jul 2021 23:18:04 +0930
Subject: [PATCH] PR28048, heap-buffer-overflow on readelf -Ww
PR 28048
* dwarf.c (get_type_signedness): Don't run off end of buffer
printing DW_FORM_string attribute.
---
binutils/dwarf.c | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index de9d2b8c8f54..1e7f4db7b7c8 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -2211,7 +2211,7 @@ get_type_signedness (abbrev_entry *entry,
if (attr->form == DW_FORM_strp)
printf (", %s", fetch_indirect_string (uvalue));
else if (attr->form == DW_FORM_string)
- printf (", %s", orig_data);
+ printf (", %.*s", (int) (end - orig_data), orig_data);
}
break;