acl-devel
[Top][All Lists]
Advanced

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

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


From: Jeff Layton
Subject: [Acl-devel] [PATCH] getfattr: don't count terminating NULL in well_enough_printable
Date: Thu, 13 Jun 2019 10:55:35 -0400

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])
+               size--;
+
        for (n=0; n < size; n++)
                if (!isprint(*value++))
                        nonpr++;
-- 
2.21.0




reply via email to

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