[PATCH] update: minor fixes in remote.c

Philippe GIACINTI Philippe.Giacinti@sxb.bsf.alcatel.fr
Sat Apr 1 00:00:00 GMT 2000


Andrew Cagney <ac131313@cygnus.com> wrote:
 > Philippe GIACINTI wrote:
 > 
 > > @@ -3439,7 +3439,8 @@
 > >        int todo;
 > >        int i;
 > > 
 > > -      todo = min (len, max_buf_size / 2);      /* num bytes that will fit */
 > > +      todo = min (len, max_buf_size / 2 - 2);  /* num bytes that will fit */
 > > +      /* -2 for leading $ and trailing # + checksum (2 hex chars) */
 > > 
 > >        /* construct "m"<memaddr>","<len>" */
 > >        /* sprintf (buf, "m%lx,%x", (unsigned long) memaddr, todo); */
 > > 
 > > If the host side needs to read for example 500 bytes and assuming that the
 > > maximum buffer size is 400 chars, then without the fix, the remote side will
 > > be asked to send min (500, 400/2)=200 bytes, its answer will then be:
 > >    $ ... 200 hex encoded bytes = 400 chars #CS = 400 + 4 chars which is greater
 > > than the max buffer size and will lead to an error from the host side.
 > > So we need to subtract 4 chars (i.e.: 2 hex encoded bytes) from requested
 > > number of bytes.
 > 
 > I'm still not sure that there is a problem here (I'm not saying that
 > there isn't though).  Several changes late last year and the testsuite
 > addition remote.exp addressed/tested many of the buffer overflow
 > problems that were lingering in that code.
 > 
 > Do you have a debug session or test case that demonstrates the problem?
 > 
 > One thing to keep in mind is that, when receiving packets, the ``$'' and
 > ``#NN'' are not included in the size of incomming packets as the remote
 > code does not use the packet buffer for those characters.
 > 
 > 	Andrew
 > 
OK, you're right. I've checked with the last snapshot, and the problem doesn't
happen anymore. I had this problem with GDB-4.18 (see attached log) and fixed
it with the previous patch.
Sorry for the inconvenience ...
Anyway, the first part of the patch (using set_thread) should be OK.

Regards.
-- 
Philippe Giacinti - Alcatel Business Systems - PCD/SMB/SWPCC - CC S0645
1, route du Dr Albert Schweitzer - 67408 Illkirch Cedex - FRANCE
Tel: +33 (0)3.90.67.62.10 - Fax: +33 (0)3.90.67.77.93
mailto:Philippe.Giacinti@sxb.bsf.alcatel.fr



More information about the Gdb-patches mailing list