From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Snyder To: "John S. Kallal" Cc: gdb-patches@sources.redhat.com Subject: Re: [PATCH] Fix some error added with HEX2BIN, 2nd version Date: Thu, 17 May 2001 10:54:00 -0000 Message-id: <3B04103A.E8D873A9@cygnus.com> References: X-SW-Source: 2001-05/msg00346.html "John S. Kallal" wrote: > > Forget about the code clean-up for now. > Maybe I will do the whole file later. > Here is just the bug fixes. > > I think there is another place where > hex2bin() is called that also have pointer update > problems. I did NOT review and change all area > that make a call to function hex2bin as I have > no way of testing other areas in file remote.c. > However function remote_async_wait() seem to have > the same problem. Thank you. I'll accept this patch and check it in. I'll investigate to see if remote_async_wait needs the same fix. Michael > > 2001-05-16 John S Kallal > > * remote.c (remote_wait): Added new local variable fieldsize. > (remote_wait) : Using fieldsize to save number of bytes read by > the call to hex2bin(). Update buffer reading pointer using > value of variable fieldsize. This fixes a bug added when > the hex2bin() call was added. > > * remote.c (remote_write_bytes) : Fix string pointer > update bug and string non-termination bug added when > function hex2bin() call was added. > > --- ../gdb+dejagnu-20010516-org/gdb/remote.c Wed May 16 12:03:47 2001 > +++ gdb/remote.c Wed May 16 12:10:10 2001 > @@ -2862,6 +2862,8 @@ Packet: '%s'\n", > } > else > { > + int fieldsize; > + > p = p1; > > if (*p++ != ':') > @@ -2874,8 +2876,9 @@ Packet: '%s'\n", > Packet: '%s'\n", > regno, p, buf); > > - if (hex2bin (p, regs, REGISTER_RAW_SIZE (regno)) > - < REGISTER_RAW_SIZE (regno)) > + fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (regno)); > + p += 2*fieldsize; > + if ( fieldsize < REGISTER_RAW_SIZE (regno)) > warning ("Remote reply is too short: %s", buf); > supply_register (regno, regs); > } > @@ -3628,6 +3631,8 @@ remote_write_bytes (CORE_ADDR memaddr, c > increasing byte addresses. Each byte is encoded as a two hex > value. */ > nr_bytes = bin2hex (myaddr, p, todo); > + p += 2*nr_bytes; > + *p = '0'; > break; > case PACKET_SUPPORT_UNKNOWN: > internal_error (__FILE__, __LINE__,