From patchwork Tue Nov 6 19:04:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 30045 Received: (qmail 44603 invoked by alias); 6 Nov 2018 19:09:42 -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 44571 invoked by uid 89); 6 Nov 2018 19:09:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.2 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= 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, 06 Nov 2018 19:09:36 +0000 Received: from ralph.com (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 425A910B670 for ; Tue, 6 Nov 2018 14:09:34 -0500 (EST) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH] Fix unsigned overflow in minsyms reader. Date: Tue, 6 Nov 2018 11:04:23 -0800 Message-Id: <20181106190423.70494-1-jhb@FreeBSD.org> X-IsSubscribed: yes Use a ssize_t helper variable for the number of bytes to shrink the msymbols obstack rather than relying on unsigned overflow to shrink the size of the obstack. gdb/ChangeLog: * minsyms.c (minimal_symbol_reader::install): Fix unsigned overflow. --- gdb/ChangeLog | 5 +++++ gdb/minsyms.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 68ecef7728..4120c62f33 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-11-06 John Baldwin + + * minsyms.c (minimal_symbol_reader::install): Fix unsigned + overflow. + 2018-11-06 John Baldwin * riscv-fbsd-nat.c (getregs_supplies): Return true for diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 4409e6f8b3..0f854422e0 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1375,8 +1375,9 @@ minimal_symbol_reader::install () mcount = compact_minimal_symbols (msymbols, mcount, m_objfile); - obstack_blank_fast (&m_objfile->per_bfd->storage_obstack, - (mcount + 1 - alloc_count) * sizeof (struct minimal_symbol)); + ssize_t shrink_bytes + = (mcount + 1 - alloc_count) * sizeof (struct minimal_symbol); + obstack_blank_fast (&m_objfile->per_bfd->storage_obstack, shrink_bytes); msymbols = (struct minimal_symbol *) obstack_finish (&m_objfile->per_bfd->storage_obstack);