xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] tools/xl: Fix trim() following c/s e316316 "xl: Rewrite trim()"
Date: Thu, 16 Jul 2015 23:30:32 +0100	[thread overview]
Message-ID: <20150716223032.GA1707@zion.uk.xensource.com> (raw)
In-Reply-To: <55A827BE.2030908@citrix.com>

On Thu, Jul 16, 2015 at 10:53:02PM +0100, Andrew Cooper wrote:
> On 16/07/2015 21:47, Wei Liu wrote:
> > On Thu, Jul 16, 2015 at 08:18:31PM +0100, Andrew Cooper wrote:
> >> c/s e316316 "xl: Rewrite trim()" uses the wrong indirection of
> >> 'output', causing memory corruption for all callers.
> >>
> >> Introduce a new local variable, making the code more obviously
> >> correct.
> >>
> >> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> >> CC: Ian Campbell <Ian.Campbell@citrix.com>
> >> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> >> CC: Wei Liu <wei.liu2@citrix.com>
> > Acked-by: Wei Liu <wei.liu2@citrix.com>
> >
> > One nit below.
> >
> >> ---
> >>  tools/libxl/xl_cmdimpl.c |    8 +++++---
> >>  1 file changed, 5 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> >> index 37d4af6..0cc9f8b 100644
> >> --- a/tools/libxl/xl_cmdimpl.c
> >> +++ b/tools/libxl/xl_cmdimpl.c
> >> @@ -663,10 +663,12 @@ static void trim(char_predicate_t predicate, const char *input, char **output)
> >>          ;
> >>  
> >>      size_t len_nonnull = after - first;
> >> +    char *result = xmalloc(len_nonnull + 1);
> >>  
> > Can you move the declaration of result to the beginning of this
> > function?
> 
> I can, but why in particular?  It is adjacent to the declaration of
> len_nonnull.
> 

C90 forbids this. Not sure how much we care about that and I'm probably
bicksheding too much.

Wei.

> ~Andrew

  reply	other threads:[~2015-07-16 22:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 19:18 [PATCH] tools/xl: Fix trim() following c/s e316316 "xl: Rewrite trim()" Andrew Cooper
2015-07-16 20:47 ` Wei Liu
2015-07-16 21:53   ` Andrew Cooper
2015-07-16 22:30     ` Wei Liu [this message]
2015-07-17 10:04       ` Ian Jackson
2015-07-17 10:18       ` Ian Campbell
2015-07-17 10:04 ` Ian Jackson

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=20150716223032.GA1707@zion.uk.xensource.com \
    --to=wei.liu2@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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;
as well as URLs for NNTP newsgroup(s).