From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107362 invoked by alias); 13 Jun 2016 18:23:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 107349 invoked by uid 89); 13 Jun 2016 18:23:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1530, satisfied X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 13 Jun 2016 18:23:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id DD48D1170D6; Mon, 13 Jun 2016 14:23:25 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 07ep2y1IMN8B; Mon, 13 Jun 2016 14:23:25 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id A9675116E1E; Mon, 13 Jun 2016 14:23:25 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 148C8428DE; Mon, 13 Jun 2016 11:23:24 -0700 (PDT) Date: Mon, 13 Jun 2016 18:23:00 -0000 From: Joel Brobecker To: David Taylor Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] symtab.c -- Fix off by one allocation bug Message-ID: <20160613182324.GB3910@adacore.com> References: <31327.1465840699@usendtaylorx2l> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <31327.1465840699@usendtaylorx2l> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2016-06/txt/msg00247.txt.bz2 > This fixes a problem found by valgrind. Applying this patch caused no > regressions on GNU/Linux x86-64 and satisfied valgrind. > > * gdb/symtab.c (symbol_set_names): Fix off by one error in > allocation. Thanks for the patch. Can you give a little more detail as to why we need that extra byte, and provide that information in the revision log. This kind of information is always very precious when doing archelogy. Thanks! > --- > gdb/ChangeLog | 4 ++++ > gdb/symtab.c | 2 +- > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 9c09269..aaeeb6e 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,3 +1,7 @@ > +2016-06-09 David Taylor > + > + * symtab.c (symbol_set_names): Fix off by one error in allocation. > + > 2016-06-07 Simon Marchi > > * mi/mi-interp.c (mi_record_changed): Add missing braces. > diff --git a/gdb/symtab.c b/gdb/symtab.c > index f7a207a..12e1cf5 100644 > --- a/gdb/symtab.c > +++ b/gdb/symtab.c > @@ -1010,7 +1010,7 @@ symbol_set_names (struct general_symbol_info *gsymbol, > = ((struct demangled_name_entry *) > obstack_alloc (&per_bfd->storage_obstack, > offsetof (struct demangled_name_entry, demangled) > - + lookup_len + demangled_len + 2)); > + + lookup_len + demangled_len + 3)); > mangled_ptr = &((*slot)->demangled[demangled_len + 1]); > strcpy (mangled_ptr, lookup_name); > (*slot)->mangled = mangled_ptr; > -- > 1.9.1 -- Joel