xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-devtools/binutils/binutils/0017-CVE-2022-38127-4.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From e98e7d9a70dcc987bff0e925f20b78cd4a2979ed Mon Sep 17 00:00:00 2001
2From: Nick Clifton <nickc@redhat.com>
3Date: Mon, 27 Jun 2022 13:30:35 +0100
4Subject: [PATCH] Fix NULL pointer indirection when parsing corrupt DWARF data.
5
6	PR 29290
7	* dwarf.c (read_and_display_attr_value): Check that debug_info_p
8	is set before dereferencing it.
9
10Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e98e7d9a70dcc987bff0e925f20b78cd4a2979ed]
11
12Signed-off-by: Pgowda <pgowda.cve@gmail.com>
13---
14 binutils/dwarf.c   | 11 +++++------
15
16diff --git a/binutils/dwarf.c b/binutils/dwarf.c
17index bcabb61b871..37b477b886d 100644
18--- a/binutils/dwarf.c
19+++ b/binutils/dwarf.c
20@@ -2727,18 +2727,17 @@ read_and_display_attr_value (unsigned lo
21 	{
22 	  const char *suffix = strrchr (section->name, '.');
23 	  bool dwo = suffix && strcmp (suffix, ".dwo") == 0;
24+	  const char *strng;
25
26+	  strng = fetch_indexed_string (uvalue, this_set, offset_size, dwo,
27+					debug_info_p ? debug_info_p->str_offsets_base : 0);
28 	  if (do_wide)
29 	    /* We have already displayed the form name.  */
30 	    printf (_("%c(offset: 0x%s): %s"), delimiter,
31-		    dwarf_vmatoa ("x", uvalue),
32-		    fetch_indexed_string (uvalue, this_set, offset_size, dwo,
33-	                                  debug_info_p->str_offsets_base));
34+		    dwarf_vmatoa ("x", uvalue), strng);
35 	  else
36 	    printf (_("%c(indexed string: 0x%s): %s"), delimiter,
37-		    dwarf_vmatoa ("x", uvalue),
38-		    fetch_indexed_string (uvalue, this_set, offset_size, dwo,
39-	                                  debug_info_p->str_offsets_base));
40+		    dwarf_vmatoa ("x", uvalue), strng);
41 	}
42       break;
43
44