From patchwork Fri Aug 21 21:23:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 8373 Received: (qmail 118588 invoked by alias); 21 Aug 2015 21:23:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 118574 invoked by uid 89); 21 Aug 2015 21:23:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 21 Aug 2015 21:23:32 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id CE63B8C1BD for ; Fri, 21 Aug 2015 21:23:30 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7LLNTVV020655 for ; Fri, 21 Aug 2015 17:23:30 -0400 Subject: [PATCH v12 25/32] Verify the build-id From: Jan Kratochvil To: gdb-patches@sourceware.org Date: Fri, 21 Aug 2015 23:23:29 +0200 Message-ID: <20150821212329.6673.76030.stgit@host1.jankratochvil.net> In-Reply-To: <20150821212006.6673.35100.stgit@host1.jankratochvil.net> References: <20150821212006.6673.35100.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes Hi, now it is possible to filter-out from openp() search files with non-matching build-id. Jan gdb/ChangeLog 2015-08-20 Jan Kratochvil * source.c: Include build-id.h. (file_location_from_filename): Call build_id_verify for the build-id parameters. --- 0 files changed diff --git a/gdb/source.c b/gdb/source.c index 9a38df4..e5684da 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -29,6 +29,7 @@ #include "filestuff.h" #include "inferior.h" #include "gdb/fileio.h" +#include "build-id.h" #include #include @@ -848,7 +849,7 @@ file_location_from_filename (const char *filename, enum openp_flags opts, } } - if ((opts & OPF_IS_BFD) == 0) + if ((build_idsz == 0 || !validate_build_id) && (opts & OPF_IS_BFD) == 0) { discard_cleanups (back_to); return file; @@ -908,6 +909,27 @@ file_location_from_filename (const char *filename, enum openp_flags opts, return file; } + if (build_idsz == 0 || !validate_build_id) + { + gdb_assert ((opts & OPF_IS_BFD) != 0); + discard_cleanups (back_to); + return file; + } + + if (!build_id_verify (file.abfd, build_idsz, build_id)) + { + do_cleanups (back_to); + file_location_enoent (&file); + return file; + } + + if ((opts & OPF_IS_BFD) == 0) + { + gdb_bfd_unref (file.abfd); + file.abfd = NULL; + gdb_assert (file.fd != -1); + } + discard_cleanups (back_to); return file; }