]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Make sure id_path can contain max number of build id bytes.
authorMark Wielaard <mark@klomp.org>
Tue, 5 Jun 2018 19:29:27 +0000 (21:29 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 8 Jun 2018 10:03:14 +0000 (12:03 +0200)
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
libdw/dwarf_getalt.c

index 17acb909d8d878b699435c64240cbb12b9974d56..b9f177dee9f391e2e7e076eed94fd7fb2932280e 100644 (file)
@@ -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
index 3339b3e1be8c29028d48012ffe94495f2340d529..0a12dfae96772bf49033da744d5db9255aaf3440 100644 (file)
@@ -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]);