From: Alejandro Colomar Date: Fri, 13 Dec 2024 02:49:49 +0000 (+0100) Subject: lib/fields.c: valid_field(): Use strchriscntrl() instead of its pattern X-Git-Tag: 4.18.0-rc1~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb5f9db28318f9b4a432fb9bba9ffa230c7b48ec;p=thirdparty%2Fshadow.git lib/fields.c: valid_field(): Use strchriscntrl() instead of its pattern Signed-off-by: Alejandro Colomar --- diff --git a/lib/fields.c b/lib/fields.c index 1f6d0ac29..67c90b91c 100644 --- a/lib/fields.c +++ b/lib/fields.c @@ -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" @@ -36,22 +37,14 @@ 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, ""))