From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4504 invoked by alias); 19 Mar 2010 09:26:09 -0000 Received: (qmail 4488 invoked by uid 22791); 19 Mar 2010 09:26:08 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Mar 2010 09:26:02 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id o2J9PoJP002930; Fri, 19 Mar 2010 10:25:50 +0100 (CET) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id o2J9Pn8q004109; Fri, 19 Mar 2010 10:25:49 +0100 (CET) Date: Fri, 19 Mar 2010 09:26:00 -0000 Message-Id: <201003190925.o2J9Pn8q004109@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: vapier@gentoo.org CC: gdb-patches@sourceware.org In-reply-to: <1268964549-30380-1-git-send-email-vapier@gentoo.org> (message from Mike Frysinger on Thu, 18 Mar 2010 22:09:09 -0400) Subject: Re: [PATCH] gdb: fix sparc memcpy fortify error References: <1268964549-30380-1-git-send-email-vapier@gentoo.org> 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 X-SW-Source: 2010-03/txt/msg00725.txt.bz2 > From: Mike Frysinger > Date: Thu, 18 Mar 2010 22:09:09 -0400 > > Building on an x86_64-linux system with --enable-targets=all fails on the > sparc code with a fortify error: > > cc1: warnings being treated as errors > In file included from /usr/include/string.h:640, > from gnulib/string.h:23, > from ../../gdb/gdb_string.h:25, > from ../../gdb/vec.h:25, > from ../../gdb/memattr.h:24, > from ../../gdb/target.h:60, > from ../../gdb/exec.h:23, > from ../../gdb/gdbcore.h:31, > from ../../gdb/sparc-tdep.c:29: > In function 'memcpy', > inlined from 'sparc32_store_return_value' at ../../gdb/sparc-tdep.c:1112, > inlined from 'sparc32_return_value' at ../../gdb/sparc-tdep.c:1170: > /usr/include/bits/string3.h:52: error: call to __builtin___memcpy_chk will > always overflow destination buffer > make: *** [sparc-tdep.o] Error 1 That's a false positive I'm afraid. I agree that it isn't trivial to see that there is no buffer overflow here. Unfortunately your solution is a bit problematic: > 2010-03-18 Mike Frysinger > > * gdb/sparc-tdep.c (sparc32_store_return_value): Declare the length > of buf using the "len" variable. > > gdb/sparc-tdep.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c > index f129a55..ea0cdd2 100644 > --- a/gdb/sparc-tdep.c > +++ b/gdb/sparc-tdep.c > @@ -1101,7 +1101,7 @@ sparc32_store_return_value (struct type *type, struct regcache *regcache, > const gdb_byte *valbuf) > { > int len = TYPE_LENGTH (type); > - gdb_byte buf[8]; > + gdb_byte buf[max(len, 8)]; Sorry, but variable sized arrays aren't C90. Does it help if you replace > gdb_assert (!(sparc_floating_p (type) && len == 16)); with gdb_assert (len <= 8); ?