Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb: fix sparc memcpy fortify error
@ 2010-03-19  2:09 Mike Frysinger
  2010-03-19  7:45 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Mike Frysinger @ 2010-03-19  2:09 UTC (permalink / raw)
  To: gdb-patches

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

So have the buffer be the max of the lengths used with memcpy().

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
2010-03-18  Mike Frysinger  <vapier@gentoo.org>

	* 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)];
 
   gdb_assert (!sparc_structure_or_union_p (type));
   gdb_assert (!(sparc_floating_p (type) && len == 16));
-- 
1.7.0.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-04-21 20:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-19  2:09 [PATCH] gdb: fix sparc memcpy fortify error Mike Frysinger
2010-03-19  7:45 ` Eli Zaretskii
2010-03-19  8:18   ` Hui Zhu
2010-03-19  8:42     ` Andreas Schwab
2010-03-19 17:10     ` Mike Frysinger
2010-03-19  9:26 ` Mark Kettenis
2010-03-19 17:09   ` Mike Frysinger
2010-03-19 20:11 ` [PATCH] gdb: workaround " Mike Frysinger
2010-04-19 18:59   ` Mike Frysinger
2010-04-21 15:30     ` Joel Brobecker
2010-04-21 15:38       ` Tom Tromey
2010-04-21 16:01         ` Joel Brobecker
2010-04-21 16:10           ` Mark Kettenis
2010-04-21 19:40             ` Mike Frysinger
2010-04-21 19:56               ` Mark Kettenis
2010-04-21 20:12                 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox