This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

FYI: Reduce packet size by one


FYI,

If you study the existing stubs you'll notice that the contain many
potential overflow problems.  This patch reduces what GDB uses as a
default packet size to one less than the magic 400 found in most stubs. 
That should greatly reduce the occurance of buffer overruns.

Thanks to Kevin Buettner for fully analyzing this problem.

	enjoy,
		Andrew

PS: There is also a few extra tests.  However, since the patch comes to
~4000 lines I'll spare people the details :-)
Sat Dec  4 15:17:44 1999  Andrew Cagney  <cagney@b1.cygnus.com>

	* remote.c (build_remote_packet_sizes): Reduce the default packet
 	size of 400 bytes by one to 399.  Stops GDB trashing stubs that
 	append a trailing NUL to an already full buffer.

Index: remote.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/remote.c,v
retrieving revision 1.261
diff -p -r1.261 remote.c
*** remote.c	1999/12/04 04:00:29	1.261
--- remote.c	1999/12/04 06:06:09
*************** register_remote_packet_sizes (void)
*** 497,505 ****
  static void
  build_remote_packet_sizes (void)
  {
!   /* Maximum number of characters in a packet. This default m68k-stub.c and
!      i386-stub.c stubs. */
!   remote_packet_size = 400;
    /* Should REGISTER_BYTES needs more space than the default, adjust
       the size accordingly. Remember that each byte is encoded as two
       characters. 32 is the overhead for the packet header /
--- 497,510 ----
  static void
  build_remote_packet_sizes (void)
  {
!   /* Default maximum number of characters in a packet body. Many
!      remote stubs have a hardwired buffer size of 400 bytes
!      (c.f. BUFMAX in m68k-stub.c and i386-stub.c).  BUFMAX-1 is used
!      as the maximum packet-size to ensure that the packet and an extra
!      NUL character can always fit in the buffer.  This stops GDB
!      trashing stubs that try to squeeze an extra NUL into what is
!      already a full buffer (As of 1999-12-04 that was most stubs. */
!   remote_packet_size = 400 - 1;
    /* Should REGISTER_BYTES needs more space than the default, adjust
       the size accordingly. Remember that each byte is encoded as two
       characters. 32 is the overhead for the packet header /

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]