diff --git a/lib/chkname.c b/lib/chkname.c index 98f791706..448bc91fb 100644 --- a/lib/chkname.c +++ b/lib/chkname.c @@ -33,6 +33,7 @@ #include "defines.h" #include "chkname.h" +#include "string/ctype/strisascii/strisdigit.h" #include "string/strcmp/streq.h" @@ -69,7 +70,11 @@ is_valid_name(const char *name) * * Also do not allow fully numeric names or just "." or "..". */ - int numeric; + + if (strisdigit(name)) { + errno = EINVAL; + return false; + } if ('\0' == *name || ('.' == *name && (('.' == name[1] && '\0' == name[2]) || @@ -84,8 +89,6 @@ is_valid_name(const char *name) return false; } - numeric = isdigit(*name); - while (!streq(++name, "")) { if (!((*name >= 'a' && *name <= 'z') || (*name >= 'A' && *name <= 'Z') || @@ -99,12 +102,6 @@ is_valid_name(const char *name) errno = EINVAL; return false; } - numeric &= isdigit(*name); - } - - if (numeric) { - errno = EINVAL; - return false; } return true; diff --git a/lib/strtoday.c b/lib/strtoday.c index 01f2e9b7e..010f12a39 100644 --- a/lib/strtoday.c +++ b/lib/strtoday.c @@ -14,6 +14,7 @@ #include "atoi/str2i/str2s.h" #include "getdate.h" #include "prototypes.h" +#include "string/ctype/strisascii/strisdigit.h" #include "string/strchr/stpspn.h" #include "string/strcmp/streq.h" @@ -35,7 +36,6 @@ long strtoday (const char *str) { time_t t; - bool isnum = true; const char *s = str; /* @@ -54,14 +54,9 @@ long strtoday (const char *str) s++; } s = stpspn(s, " "); - while (isnum && !streq(s, "")) { - if (!isdigit (*s)) { - isnum = false; - } - s++; - } - if (isnum) { + if (strisdigit(s)) { long retdate; + if (str2sl(&retdate, str) == -1) return -2; return retdate; diff --git a/lib/subordinateio.c b/lib/subordinateio.c index bf02328e7..229f27cb3 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -22,6 +22,7 @@ #include "alloc/realloc.h" #include "alloc/reallocf.h" #include "atoi/str2i/str2u.h" +#include "string/ctype/strisascii/strisdigit.h" #include "string/sprintf/snprintf.h" #include "string/strcmp/streq.h" @@ -926,22 +927,12 @@ int list_owner_ranges(const char *owner, enum subid_type id_type, struct subid_r return count; } -static bool all_digits(const char *str) -{ - int i; - - for (i = 0; str[i] != '\0'; i++) - if (!isdigit(str[i])) - return false; - return true; -} - static int append_uids(uid_t **uids, const char *owner, int n) { int i; uid_t owner_uid; - if (all_digits(owner)) { + if (strisdigit(owner)) { i = sscanf(owner, "%d", &owner_uid); if (i != 1) { // should not happen