From patchwork Tue Sep 18 18:54:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 29439 Received: (qmail 100535 invoked by alias); 18 Sep 2018 18:55:13 -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 100518 invoked by uid 89); 18 Sep 2018 18:55:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=KF_FD, KF_PATH, kf_path, KF_TYPE X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Sep 2018 18:55:10 +0000 Received: from ralph.com (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 4253D10AFD2 for ; Tue, 18 Sep 2018 14:55:08 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v3 1/8] Use KF_PATH to verify the size of a struct kinfo_file. Date: Tue, 18 Sep 2018 11:54:37 -0700 Message-Id: <20180918185444.89533-2-jhb@FreeBSD.org> In-Reply-To: <20180918185444.89533-1-jhb@FreeBSD.org> References: <20180918185444.89533-1-jhb@FreeBSD.org> X-IsSubscribed: yes fbsd_core_vnode_path needs to use the offset of the kf_path member of struct kinfo_file as the minimum size of a struct kinfo_file object. However, it was using KVE_PATH instead due to a copy and paste bug. While here, fix another copy and paste bug in the error message for a truncated kinfo_file object. gdb/ChangeLog: * fbsd-tdep.c (fbsd_core_vnode_path): Use KF_PATH instead of KVE_PATH. --- gdb/ChangeLog | 5 +++++ gdb/fbsd-tdep.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a468d8dc32..14ac0dae52 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-09-17 John Baldwin + + * fbsd-tdep.c (fbsd_core_vnode_path): Use KF_PATH instead of + KVE_PATH. + 2018-09-17 Philippe Waroquiers * python/lib/gdb/command/frame_filters.py (EnableFrameFilter): diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index ed43087169..48544b5370 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -781,13 +781,13 @@ fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd) /* Skip over the structure size. */ descdata += 4; - while (descdata + KVE_PATH < descend) + while (descdata + KF_PATH < descend) { ULONGEST structsize; structsize = bfd_get_32 (core_bfd, descdata + KF_STRUCTSIZE); - if (structsize < KVE_PATH) - error (_("malformed core note - vmmap entry too small")); + if (structsize < KF_PATH) + error (_("malformed core note - file structure too small")); if (bfd_get_32 (core_bfd, descdata + KF_TYPE) == KINFO_FILE_TYPE_VNODE && bfd_get_signed_32 (core_bfd, descdata + KF_FD) == fd)