From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 4CB273858D33; Thu, 11 Apr 2024 23:41:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CB273858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712878895; bh=mEI83nnnRfMU7OwI4v2xjkuFk/bo8It2cO1+0kbDUYk=; h=From:To:Subject:Date:From; b=GJB9AugJXgZb0tA+R1KoHaAPlbMvnqni1yRjFZHNigDHmC7ZKTLvsbrD4kXWOqme8 jKojukCtp4RPhMeY1L/nPeZA4D3PA/mL5BEUC1nxz3KK1Poch5bjQQOte6FyK3C52w rczyz+XHfL28ESIsOwqupJsPOel2k7ve4Zl+Gu2w= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: binutils-cvs@sourceware.org Subject: [binutils-gdb] Re: Fix null pointer dereference in process_debug_info() X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: fcf8f3237cbaa0f97e57a161d7354cdb89a1ffa4 X-Git-Newrev: 0f8adbf77dd3f40e74529fa989dca034c73a7273 Message-Id: <20240411234135.4CB273858D33@sourceware.org> Date: Thu, 11 Apr 2024 23:41:35 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D0f8adbf77dd3= f40e74529fa989dca034c73a7273 commit 0f8adbf77dd3f40e74529fa989dca034c73a7273 Author: Alan Modra Date: Fri Apr 12 08:55:02 2024 +0930 Re: Fix null pointer dereference in process_debug_info() =20 read_bases has a potential null-pointer deref too, and without a debug_info_p there isn't any point in calling read_bases. =20 * dwarf.c (process_debug_info): Don't call read_bases when debug_info_p is NULL. Diff: --- binutils/dwarf.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/binutils/dwarf.c b/binutils/dwarf.c index ce508d0315f..3ce79f4e5d1 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -4236,7 +4236,7 @@ process_debug_info (struct dwarf_section * section, Only needed for the top DIE on DWARFv5+. No simiar treatment for loclists_base because there should be no loclist attributes in top DIE. */ - if (compunit.cu_version >=3D 5 && level =3D=3D 0) + if (debug_info_p && compunit.cu_version >=3D 5 && level =3D=3D 0) { int64_t stemp; =20 @@ -4248,17 +4248,14 @@ process_debug_info (struct dwarf_section * section, compunit.cu_version, debug_info_p); =20 - if (debug_info_p) + /* This check was in place before, keep it. */ + stemp =3D debug_info_p->rnglists_base; + if (stemp < 0) { - /* This check was in place before, keep it. */ - stemp =3D debug_info_p->rnglists_base; - if (stemp < 0) - { - warn (_("CU @ %#" PRIx64 " has has a negative rnglists_base " - "value of %#" PRIx64 " - treating as zero"), - debug_info_p->cu_offset, stemp); - debug_info_p->rnglists_base =3D 0; - } + warn (_("CU @ %#" PRIx64 " has has a negative rnglists_base " + "value of %#" PRIx64 " - treating as zero"), + debug_info_p->cu_offset, stemp); + debug_info_p->rnglists_base =3D 0; } }