diff options
author | Denis Vlasenko | 2008-03-19 23:25:00 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-03-19 23:25:00 +0000 |
commit | 104d544fd740c9d583893a476935f0e7fd44345c (patch) | |
tree | f588f5ed7e067678ace08d13f8c9574f7d56c338 /libbb/die_if_bad_username.c | |
parent | dd5702d696b9ab5a5b3939d660658b7f0e6694ed (diff) | |
download | busybox-104d544fd740c9d583893a476935f0e7fd44345c.zip busybox-104d544fd740c9d583893a476935f0e7fd44345c.tar.gz |
die_if_bad_username: shrink: 88 -> 77 bytes
Diffstat (limited to 'libbb/die_if_bad_username.c')
-rw-r--r-- | libbb/die_if_bad_username.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/libbb/die_if_bad_username.c b/libbb/die_if_bad_username.c index 251b1f0..337ac60 100644 --- a/libbb/die_if_bad_username.c +++ b/libbb/die_if_bad_username.c @@ -18,17 +18,19 @@ void die_if_bad_username(const char *name) { - int i = 0; - + goto skip; /* 1st char being dash isn't valid */ do { - if (!isalnum(*name) - && !(*name == '_') - && !(*name == '.') - && !(*name == '@') - && !(*name == '-' && i) - && !(*name == '$' && !*(name + 1)) - ) - bb_error_msg_and_die("illegal character '%c'", *name); - i++; + if (*name == '-') + continue; + skip: + if (isalnum(*name) + || *name == '_' + || *name == '.' + || *name == '@' + || (*name == '$' && !*(name + 1)) + ) { + continue; + } + bb_error_msg_and_die("illegal character '%c'", *name); } while (*++name); } |