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: Andreas Gruenbacher
Subject: Re: [Acl-devel] [PATCH] getfattr: don't count terminating NULL in well_enough_printable
Date: Thu, 13 Jun 2019 22:50:41 +0200

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.

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

Thanks,
Andreas



reply via email to

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