Skip to content

Commit

Permalink
lib/chkname.c: is_valid_name(): Use streq() instead of its pattern
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Dec 6, 2024
1 parent b75ea29 commit d335844
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/chkname.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
#include <sys/param.h>
#include <unistd.h>

#include "defines.h"
#include "chkname.h"
#include "defines.h"
#include "string/strcmp/streq.h"


int allow_bad_names = false;
Expand Down Expand Up @@ -70,9 +71,9 @@ is_valid_name(const char *name)
*/
int numeric;

if ('\0' == *name ||
('.' == *name && (('.' == name[1] && '\0' == name[2]) ||
'\0' == name[1])) ||
if (streq(name, "") ||
streq(name, ".") ||
streq(name, "..") ||
!((*name >= 'a' && *name <= 'z') ||
(*name >= 'A' && *name <= 'Z') ||
(*name >= '0' && *name <= '9') ||
Expand All @@ -92,7 +93,7 @@ is_valid_name(const char *name)
*name == '_' ||
*name == '.' ||
*name == '-' ||
(*name == '$' && name[1] == '\0')
streq(name, "$")
))
{
errno = EINVAL;
Expand Down

0 comments on commit d335844

Please sign in to comment.