public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Subject: Re: [PATCH] libdw: Resolve alt file on first use.
Date: Thu, 25 Jan 2018 15:28:00 -0000	[thread overview]
Message-ID: <1516894088.17912.97.camel@klomp.org> (raw)
In-Reply-To: <1516620651-14393-1-git-send-email-mark@klomp.org>

On Mon, 2018-01-22 at 12:30 +0100, Mark Wielaard wrote:
> +static void
> +find_debug_altlink (Dwarf *dbg)
> +{
> +  const char *altname;
> +  const void *build_id;
> +  ssize_t build_id_len = INTUSE(dwelf_dwarf_gnu_debugaltlink) (dbg,
> > +							       &altname,
> > +							       &build_id);
> +
> +  /* Couldn't even get the debugaltlink.  It probably doesn't exist.  */
> +  if (build_id_len < 0)
> +    return;

Testing under valgrind showed that this should be build_id_len <= 0.
When dwelf_dwarf_gnu_debugaltlink returns 0 it means there was no
.gnu_debugaltlink section at all. A negative return value means the
data found was corrupt. In both cases neither altname nor build_id
might be set up. So I added the following fixup:

diff --git a/libdw/dwarf_getalt.c b/libdw/dwarf_getalt.c
index 7b41a2b..3e5af15 100644
--- a/libdw/dwarf_getalt.c
+++ b/libdw/dwarf_getalt.c
@@ -117,7 +117,7 @@ find_debug_altlink (Dwarf *dbg)
                                                               &build_id);
 
   /* Couldn't even get the debugaltlink.  It probably doesn't exist.  */
-  if (build_id_len < 0)
+  if (build_id_len <= 0)
     return;
 
   const uint8_t *id = (const uint8_t *) build_id;

  reply	other threads:[~2018-01-25 15:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 11:31 Mark Wielaard
2018-01-25 15:28 ` Mark Wielaard [this message]
2018-01-29 10:53   ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516894088.17912.97.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).