Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix some error added with HEX2BIN, 2nd version
@ 2001-05-16 16:33 John S. Kallal
  2001-05-17 10:54 ` Michael Snyder
  0 siblings, 1 reply; 2+ messages in thread
From: John S. Kallal @ 2001-05-16 16:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: msnyder

	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.


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__,


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

* Re: [PATCH] Fix some error added with HEX2BIN, 2nd version
  2001-05-16 16:33 [PATCH] Fix some error added with HEX2BIN, 2nd version John S. Kallal
@ 2001-05-17 10:54 ` Michael Snyder
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Snyder @ 2001-05-17 10:54 UTC (permalink / raw)
  To: John S. Kallal; +Cc: gdb-patches

"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__,


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

end of thread, other threads:[~2001-05-17 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-16 16:33 [PATCH] Fix some error added with HEX2BIN, 2nd version John S. Kallal
2001-05-17 10:54 ` Michael Snyder

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