public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] libdw: Make sure id_path can contain max number of build id bytes.
Date: Tue, 05 Jun 2018 19:34:00 -0000	[thread overview]
Message-ID: <1528227236-15582-1-git-send-email-mark@klomp.org> (raw)

The MAX_BUILD_ID_BYTES is fairly large (64), while normally build-ids
are only 20 bytes long. But if we would encounter a jumbo build-id we
should have enough room to construct the full build-id path.

We used to substract 2 bytes from the max, because 2 chars are used
as subdir. But that should be 1 (2 hex chars is just one 8 bit byte).

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdw/ChangeLog      | 5 +++++
 libdw/dwarf_getalt.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 17acb90..b9f177d 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2018-06-05  Mark Wielaard  <mark@klomp.org>
+
+	* dwarf_getalt.c (find_debug_altlink): id_path array should be 2
+	larger to contain MAX_BUILD_ID_BYTES.
+
 2018-05-31  Mark Wielaard  <mark@klomp.org>
 
 	* libdw_find_split_unit.c (try_split_file): New function extracted
diff --git a/libdw/dwarf_getalt.c b/libdw/dwarf_getalt.c
index 3339b3e..0a12dfa 100644
--- a/libdw/dwarf_getalt.c
+++ b/libdw/dwarf_getalt.c
@@ -123,7 +123,7 @@ find_debug_altlink (Dwarf *dbg)
     {
       /* Note sizeof a string literal includes the trailing zero.  */
       char id_path[sizeof DEBUGINFO_PATH - 1 + sizeof "/.build-id/" - 1
-		   + 2 + 1 + (MAX_BUILD_ID_BYTES - 2) * 2 + sizeof ".debug"];
+		   + 2 + 1 + (MAX_BUILD_ID_BYTES - 1) * 2 + sizeof ".debug"];
       sprintf (&id_path[0], "%s%s", DEBUGINFO_PATH, "/.build-id/");
       sprintf (&id_path[sizeof DEBUGINFO_PATH - 1 + sizeof "/.build-id/" - 1],
 	       "%02" PRIx8 "/", (uint8_t) id[0]);
-- 
1.8.3.1

             reply	other threads:[~2018-06-05 19:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05 19:34 Mark Wielaard [this message]
2018-06-08 10:06 ` 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=1528227236-15582-1-git-send-email-mark@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).