From 15478324b1bd7d450ce00a8b8d8182d13e5cf4b6 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Mon, 23 Dec 2024 18:41:06 +0100 Subject: [PATCH] lib/chkname.c: is_valid_name(): Use ispfchar() to simplify In the first case, we can do the transformation because a few lines above, we explicitly reject a name starting with a '-'. In the second case, we're obviously using ispfchar() instead of its pattern. Signed-off-by: Alejandro Colomar --- lib/chkname.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/chkname.c b/lib/chkname.c index 9e01e62dc..ee9d85edc 100644 --- a/lib/chkname.c +++ b/lib/chkname.c @@ -34,6 +34,7 @@ #include "defines.h" #include "chkname.h" +#include "ctype/ispfchar.h" #include "string/ctype/strchrisascii/strchriscntrl.h" #include "string/ctype/strisascii/strisdigit.h" #include "string/strcmp/streq.h" @@ -84,10 +85,7 @@ is_valid_name(const char *name) * sake of Samba 3.x "add machine script" */ - if (!(isalnum(*name) || - *name == '_' || - *name == '.')) - { + if (!ispfchar(*name)) { errno = EILSEQ; return false; } @@ -96,12 +94,7 @@ is_valid_name(const char *name) if (streq(name, "$")) // Samba return true; - if (!(isalnum(*name) || - *name == '_' || - *name == '.' || - *name == '-' - )) - { + if (!ispfchar(*name)) { errno = EILSEQ; return false; }