aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/useradd.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/pending/useradd.c')
-rw-r--r--toys/pending/useradd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/toys/pending/useradd.c b/toys/pending/useradd.c
index 9f1fa4c5..4f2bcc61 100644
--- a/toys/pending/useradd.c
+++ b/toys/pending/useradd.c
@@ -54,8 +54,8 @@ void useradd_main(void)
}
// Sanity check user to add
- if (strchr(s, ':') || strchr(s, '/') || strlen(s) > LOGIN_NAME_MAX)
- error_exit("bad name");
+ if (s[strcspn(s, ":/\n")] || strlen(s) > LOGIN_NAME_MAX)
+ error_exit("bad username");
// race condition: two adds at same time?
if (getpwnam(s)) error_exit("'%s' in use", s);