From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68151 invoked by alias); 5 Jun 2018 19:34:03 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 68136 invoked by uid 89); 5 Jun 2018 19:34:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1599 X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Jun 2018 19:34:01 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 73696307C548; Tue, 5 Jun 2018 21:33:59 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 438EA418ABBE; Tue, 5 Jun 2018 21:33:59 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] libdw: Make sure id_path can contain max number of build id bytes. Date: Tue, 05 Jun 2018 19:34:00 -0000 Message-Id: <1528227236-15582-1-git-send-email-mark@klomp.org> X-Mailer: git-send-email 1.8.3.1 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q2/txt/msg00151.txt.bz2 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 --- 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 + + * dwarf_getalt.c (find_debug_altlink): id_path array should be 2 + larger to contain MAX_BUILD_ID_BYTES. + 2018-05-31 Mark Wielaard * 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