]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/fields.c: valid_field(): Use strisprint() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Wed, 11 Dec 2024 21:45:05 +0000 (22:45 +0100)
committerSerge Hallyn <serge@hallyn.com>
Tue, 3 Jun 2025 14:04:01 +0000 (09:04 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/fields.c

index 625a8f588c7dc75742da7d33b80715ff9dbe02a7..1f6d0ac29008d7a693799ac6d442331b73d8cd7c 100644 (file)
@@ -16,6 +16,7 @@
 #include <stdio.h>
 
 #include "prototypes.h"
+#include "string/ctype/strisascii/strisprint.h"
 #include "string/strcmp/streq.h"
 #include "string/strspn/stpspn.h"
 #include "string/strspn/stprspn.h"
@@ -36,7 +37,6 @@ int
 valid_field_(const char *field, const char *illegal)
 {
        const char *cp;
-       int err = 0;
 
        if (NULL == field) {
                return -1;
@@ -50,12 +50,14 @@ valid_field_(const char *field, const char *illegal)
                unsigned char c = *cp;
                if (iscntrl(c))
                        return -1;
-               if (!isprint (c)) {
-                       err = 1;
-               }
        }
 
-       return err;
+       if (strisprint(field))
+               return 0;
+       if (streq(field, ""))
+               return 0;
+
+       return 1;
 }
 
 /*