Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [ob] fix buf size in amd64_epilogue_frame_cache
@ 2009-12-20 19:11 Michael Snyder
  2009-12-21  4:38 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Snyder @ 2009-12-20 19:11 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 116 bytes --]

Going to treat this one as obvious.  Wrong buf size can cause
overflow and crash under inauspicious circumstances.


[-- Attachment #2: buf.txt --]
[-- Type: text/plain, Size: 695 bytes --]

2009-12-20  Michael Snyder  <msnyder@vmware.com>

	* amd64-tdep.c (amd64_epilogue_frame_cache): Fix buf size.

Index: amd64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64-tdep.c,v
retrieving revision 1.66
diff -u -p -r1.66 amd64-tdep.c
--- amd64-tdep.c	5 Nov 2009 21:17:00 -0000	1.66
+++ amd64-tdep.c	20 Dec 2009 19:08:58 -0000
@@ -1928,7 +1928,7 @@ amd64_epilogue_frame_cache (struct frame
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct amd64_frame_cache *cache;
-  gdb_byte buf[4];
+  gdb_byte buf[8];
 
   if (*this_cache)
     return *this_cache;

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

* Re: [ob] fix buf size in amd64_epilogue_frame_cache
  2009-12-20 19:11 [ob] fix buf size in amd64_epilogue_frame_cache Michael Snyder
@ 2009-12-21  4:38 ` Joel Brobecker
  2009-12-24 18:51   ` Michael Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2009-12-21  4:38 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches

> 2009-12-20  Michael Snyder  <msnyder@vmware.com>
> 
> 	* amd64-tdep.c (amd64_epilogue_frame_cache): Fix buf size.

I'm going to apply this patch to the gdb-7.0 branch as well.

> -  gdb_byte buf[4];
> +  gdb_byte buf[8];

I think we should try to avoid using litteral constants like these,
especially when we repeat that constant later.  For instance, in
this case, we could have used register_size, or something similar...

-- 
Joel


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

* Re: [ob] fix buf size in amd64_epilogue_frame_cache
  2009-12-21  4:38 ` Joel Brobecker
@ 2009-12-24 18:51   ` Michael Snyder
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Snyder @ 2009-12-24 18:51 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Joel Brobecker wrote:
>> 2009-12-20  Michael Snyder  <msnyder@vmware.com>
>>
>> 	* amd64-tdep.c (amd64_epilogue_frame_cache): Fix buf size.
> 
> I'm going to apply this patch to the gdb-7.0 branch as well.
> 
>> -  gdb_byte buf[4];
>> +  gdb_byte buf[8];
> 
> I think we should try to avoid using litteral constants like these,
> especially when we repeat that constant later.  For instance, in
> this case, we could have used register_size, or something similar...

I don't think there's a simple "register_size" constant.
There's a register_size function, but that's not a good way
to declare an array size.

There's MAX_REGISTER_SIZE, but that's 16.  A possibility.
If you've got a better suggestion...


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

end of thread, other threads:[~2009-12-24 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-20 19:11 [ob] fix buf size in amd64_epilogue_frame_cache Michael Snyder
2009-12-21  4:38 ` Joel Brobecker
2009-12-24 18:51   ` Michael Snyder

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