Quoting Christian Brauner (christianvanbrau...@gmail.com):
> On Mon, Sep 07, 2015 at 05:03:37PM +0000, Serge Hallyn wrote:
> > Quoting Serge Hallyn (serge.hal...@ubuntu.com):
> > > Quoting Christian Brauner (christianvanbrau...@gmail.com):
> > > 
> > > I'm probably wrong, but
> > > 
> > > 1. if the buffer is non-null-terminated, then can't the memmove of
> > >   strlen(del) - needlelen + 1 end up in a segv?
> > > 2. the comment should probably mention newlines.  If needle doesn't
> > >   include newline, and the string is a policy, we'll end up
> > >   with extra newlines.  Which may not matter, unless we do
> > >   thousands of operations on a container...
> > 
> > In fact, if it is not null-terminated, you can't do the strlen(del)
> > safely, can you?
> 
> Right, I would change
>         memmove(del, del + needlelen, strlen(del) - needlelen + 1);
> to
>         memmove(del, del + needlelen, strnlen(del, haystacklen) - needlelen);

Should probably be somethin glike

         memmove(del, del + needlelen, strnlen(del, haystacklen-del) - 
needlelen);
         del[needlelen] = '\0';

I'm not convinced eventhat is right.  We may need to either always assume it is
null-terminated, or always track the current valid length of the string.  
(and/or
keep extra state showing whether null-terminated or not)

> The Current master relies on the same idea in mod_rdep(), I'll send a patch 
> for
> the current master in a few minutes, unless you're on it right now.

I'm not.  Thanks.
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to