From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32289 invoked by alias); 7 Mar 2013 09:13:04 -0000 Received: (qmail 32280 invoked by uid 22791); 7 Mar 2013 09:13:03 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: sourceware.org Received: from smarthost.idnet.net (HELO smarthost.idnet.net) (212.69.40.140) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Mar 2013 09:12:57 +0000 Received: from localhost (unknown [127.0.0.1]) by smarthost.idnet.net (Postfix) with ESMTP id D211E236F4C for ; Thu, 7 Mar 2013 09:19:39 +0000 (UTC) Received: from smarthost.idnet.net ([127.0.0.1]) by localhost (smarthost.idnet.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id a7tRioZgyMwx for ; Thu, 7 Mar 2013 09:19:39 +0000 (GMT) Received: from smarthost.idnet.net (localhost.localdomain [127.0.0.1]) by smarthost.idnet.net (Postfix) with ESMTP id 381E3236F50 for ; Thu, 7 Mar 2013 09:19:39 +0000 (GMT) Received: from m3.idnet.com (unknown [212.69.40.217]) by smarthost.idnet.net (Postfix) with ESMTP id 3116C236F4B for ; Thu, 7 Mar 2013 09:19:39 +0000 (GMT) Received: from mail.idnet.net.uk (mail.idnet.net.uk [212.69.36.63]) by m3.idnet.com (Postfix) with ESMTP id DE85022CE1 for ; Thu, 7 Mar 2013 09:19:38 +0000 (GMT) Received: from [91.135.5.64] by mail.idnet.net.uk (GMS 17.01.3793/NU3963.00.7ca42f0c) with ESMTP via TLS id wbnrwcda for gdb-patches@sourceware.org; Thu, 7 Mar 2013 09:12:54 +0000 Message-ID: <1362647572.2235.151.camel@laria> Subject: Re: [PATCH PR gdb/15236] gdbserver write to linux memory with zero length corrupts stack From: Jeremy Bennett Reply-To: jeremy.bennett@embecosm.com To: Yao Qi , gdb-patches@sourceware.org, Pedro Alves Date: Thu, 07 Mar 2013 09:13:00 -0000 In-Reply-To: <513858A3.8070601@codesourcery.com> References: <1362593035.2235.57.camel@laria> <513793BD.2090804@redhat.com> <1362646336.2235.137.camel@laria> <513858A3.8070601@codesourcery.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-AuthenticatedSender: jeremy.bennett.embecosm.com@idnet.net.uk X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-03/txt/msg00267.txt.bz2 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 > > > > 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 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 + + PR server/15236 + * linux-low.c (linux_write_memory): Return early success if LEN is + zero. + 2013-03-05 Corinna Vinschen * 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