Re: [PATCH PR gdb/15236] gdbserver write to linux memory with zero length corrupts stack

Jeremy Bennett
2013-03-07T09:13:04Z

On Thu, 2013-03-07 at 17:06 +0800, Yao Qi wrote:
> On 03/07/2013 04:52 PM, Jeremy Bennett wrote:
> > 2013-03-07 Jeremy Bennett<jeremy.bennett@embecosm.com>
> >
> > PR gdb/15236
> ^^^ It should be "server".
> > * linux-low.c (linux_write_memory): Return early success if LEN is
> > zero.

Hi Yao,

My misunderstanding. Revised ChangeLog entry:

2013-03-07 Jeremy Bennett <jeremy.bennett@embecosm.com>

PR server/15236
* linux-low.c (linux_write_memory): Return early success if LEN is
zero.

and patch:

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index a8cf78c..67bc149 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-07 Jeremy Bennett <jeremy.bennett@embecosm.com>
+
+ PR server/15236
+ * linux-low.c (linux_write_memory): Return early success if LEN is
+ zero.
+
2013-03-05 Corinna Vinschen <vinschen@redhat.de>

* configure.srv: Add x86_64-*-cygwin* as target.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index c52cd2e..8eb5dac 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4481,7 +4481,7 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)

/* Copy LEN bytes of data from debugger memory at MYADDR to inferior's
memory at MEMADDR. On failure (cannot write to the inferior)
- returns the value of errno. */
+ returns the value of errno. Succeeds immediately if LEN is zero. */