Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jeremy Bennett <jeremy.bennett@embecosm.com>
To: Yao Qi <yao@codesourcery.com>,
	gdb-patches@sourceware.org, Pedro Alves	 <palves@redhat.com>
Subject: Re: [PATCH PR gdb/15236] gdbserver write to linux memory with zero length corrupts stack
Date: Thu, 07 Mar 2013 09:13:00 -0000	[thread overview]
Message-ID: <1362647572.2235.151.camel@laria> (raw)
In-Reply-To: <513858A3.8070601@codesourcery.com>

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. */
 
 static int
 linux_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
@@ -4500,6 +4500,12 @@ linux_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
 
   int pid = lwpid_of (get_thread_lwp (current_inferior));
 
+  if (len == 0)
+    {
+      /* Zero length write always succeeds. */
+      return 0;
+    }
+
   if (debug_threads)
     {
       /* Dump up to four bytes.  */

Best wishes,


Jeremy

-- 
Tel:      +44 (1590) 610184
Cell:     +44 (7970) 676050
SkypeID: jeremybennett
Email:   jeremy.bennett@embecosm.com
Web:     www.embecosm.com


  reply	other threads:[~2013-03-07  9:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06 18:04 Jeremy Bennett
2013-03-06 19:07 ` Pedro Alves
2013-03-07  8:52   ` Jeremy Bennett
2013-03-07  9:07     ` Yao Qi
2013-03-07  9:13       ` Jeremy Bennett [this message]
2013-03-07  9:56         ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1362647572.2235.151.camel@laria \
    --to=jeremy.bennett@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=yao@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox