Skip to content

Commit 1cabaf3

Browse files
lib/chkname.c: is_valid_name(): Use ispfchar_c() 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_c() instead of its pattern. Signed-off-by: Alejandro Colomar <alx@kernel.org>
1 parent 69076fb commit 1cabaf3

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/chkname.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include "defines.h"
3535
#include "chkname.h"
36+
#include "string/ctype/isascii.h"
3637
#include "string/ctype/strchrisascii.h"
3738
#include "string/ctype/strisascii.h"
3839
#include "string/strcmp/streq.h"
@@ -87,10 +88,7 @@ is_valid_name(const char *name)
8788
* sake of Samba 3.x "add machine script"
8889
*/
8990

90-
if (!(isalnum(*name) ||
91-
*name == '_' ||
92-
*name == '.'))
93-
{
91+
if (!ispfchar_c(*name)) {
9492
errno = EILSEQ;
9593
return false;
9694
}
@@ -99,12 +97,7 @@ is_valid_name(const char *name)
9997
if (streq(name, "$")) // Samba
10098
return true;
10199

102-
if (!(isalnum(*name) ||
103-
*name == '_' ||
104-
*name == '.' ||
105-
*name == '-'
106-
))
107-
{
100+
if (!ispfchar_c(*name)) {
108101
errno = EILSEQ;
109102
return false;
110103
}

0 commit comments

Comments
 (0)