]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/fields.c: valid_field(): Use strchriscntrl() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Fri, 13 Dec 2024 02:49:49 +0000 (03:49 +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 1f6d0ac29008d7a693799ac6d442331b73d8cd7c..67c90b91cc4aa8d8b15898b28699f6aab33db3f1 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "prototypes.h"
 #include "string/ctype/strisascii/strisprint.h"
+#include "string/ctype/strchrisascii/strchriscntrl.h"
 #include "string/strcmp/streq.h"
 #include "string/strspn/stpspn.h"
 #include "string/strspn/stprspn.h"
 int
 valid_field_(const char *field, const char *illegal)
 {
-       const char *cp;
-
        if (NULL == field) {
                return -1;
        }
 
        if (strpbrk(field, illegal))
                return -1;
-
-       /* Search if there are non-printable or control characters */
-       for (cp = field; !streq(cp, ""); cp++) {
-               unsigned char c = *cp;
-               if (iscntrl(c))
-                       return -1;
-       }
-
+       if (strchriscntrl(field))
+               return -1;
        if (strisprint(field))
                return 0;
        if (streq(field, ""))