acl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Acl-devel] [PATCH] getfattr: don't count terminating NULL in well_e


From: Jeff Layton
Subject: Re: [Acl-devel] [PATCH] getfattr: don't count terminating NULL in well_enough_printable
Date: Thu, 13 Jun 2019 16:59:14 -0400
User-agent: Evolution 3.32.2 (3.32.2-1.fc30)

On Thu, 2019-06-13 at 22:50 +0200, Andreas Gruenbacher wrote:
> Jeff,
> 
> On Thu, 13 Jun 2019 at 16:55, Jeff Layton <address@hidden> wrote:
> > If the value is a string with the terminating NULL included in the
> > length, then don't count that terminating NULL when determining whether
> > the string is printable.
> > 
> > Signed-off-by: Jeff Layton <address@hidden>
> > ---
> >  tools/getfattr.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/tools/getfattr.c b/tools/getfattr.c
> > index 72a885233d0a..276cd3120d8e 100644
> > --- a/tools/getfattr.c
> > +++ b/tools/getfattr.c
> > @@ -110,6 +110,10 @@ int well_enough_printable(const char *value, size_t 
> > size)
> >  {
> >         size_t n, nonpr = 0;
> > 
> > +       /* Don't count the NULL terminator if there is one */
> > +       if (!value[size - 1])
> 
> I'm adding a "size &&" check here and some more explanation in the
> commit message, but other than that, this looks fine.
> 

Good catch.

This was only lightly tested, fwiw, but it seemed to do the right thing
for the case where I was having problems.

> > +               size--;
> > +
> >         for (n=0; n < size; n++)
> >                 if (!isprint(*value++))
> >                         nonpr++;
> > --
> > 2.21.0
> > 
> 
> Thanks,
> Andreas

-- 
Jeff Layton <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]