This is the mail archive of the gdb-cvs@sourceware.org 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]
Other format: [Raw text]

[binutils-gdb] Fix '-data-read-memory-bytes' typo/assertion


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e084c964d61e6f8582711c73738c4df132410597

commit e084c964d61e6f8582711c73738c4df132410597
Author: Don Breazeal <donb@codesourcery.com>
Date:   Fri Nov 20 09:45:44 2015 -0800

    Fix '-data-read-memory-bytes' typo/assertion
    
    This patch fixes a typo in target.c:read_memory_robust, where
    it calls read_whatever_is_readable with the function arguments
    in the wrong order.  Depending on the address being read, it
    can cause an xmalloc with a huge size, resulting in an assertion
    failure, or just read something other than what was requested.
    
    The problem only arises when GDB is handling an MI
    "-data-read-memory-bytes" request and the initial target_read returns
    an error status.  Note that read_memory_robust is only called from
    the MI code.
    
    gdb/ChangeLog:
    
    	* gdb/target.c (read_memory_robust): Call
    	read_whatever_is_readable with arguments in the correct order.

Diff:
---
 gdb/ChangeLog | 5 +++++
 gdb/target.c  | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ee1b6ad..5a00b5f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2015-11-19  Don Breazeal  <donb@codesourcery.com>
+
+	* target.c (read_memory_robust): Call read_whatever_is_readable
+	with arguments in the correct order.
+
 2015-11-19  Pedro Alves  <palves@redhat.com>
 
 	* remote.c (remote_query_supported): Send the "xmlRegisters="
diff --git a/gdb/target.c b/gdb/target.c
index 0ae6708..2365cd3 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1836,8 +1836,9 @@ read_memory_robust (struct target_ops *ops,
 	      /* Got an error reading full chunk.  See if maybe we can read
 		 some subrange.  */
 	      xfree (buffer);
-	      read_whatever_is_readable (ops, offset + xfered_total, unit_size,
-					 offset + xfered_total + to_read, &result);
+	      read_whatever_is_readable (ops, offset + xfered_total,
+					 offset + xfered_total + to_read,
+					 unit_size, &result);
 	      xfered_total += to_read;
 	    }
 	  else


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