From 9b6e79cb46ef2c4e51e06d5c8d2eea09406147fb 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 3671a22dd..8026a0967 100644 --- a/lib/chkname.c +++ b/lib/chkname.c @@ -32,6 +32,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" @@ -86,10 +87,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; } @@ -98,12 +96,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; }