This is the mail archive of the gdb-patches@sources.redhat.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]

[PATCH] Fix some error added with HEX2BIN, 2nd version


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


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