This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH] Fix some error added with HEX2BIN, 2nd version
- To: "John S. Kallal" <kallal at CyberMax dot local>
- Subject: Re: [PATCH] Fix some error added with HEX2BIN, 2nd version
- From: Michael Snyder <msnyder at cygnus dot com>
- Date: Thu, 17 May 2001 10:54:02 -0700
- CC: gdb-patches at sources dot redhat dot com
- Organization: Red Hat
- References: <Pine.LNX.4.21.0105161929080.729-100000@CyberMax.local>
"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 <jskallal@home.com>
>
> * 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__,