lib/chkname.c: is_valid_user_name(): Avoid a cast
By using a temporary vairable, we can remove a cast. Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com> Cc: Tobias Stoeckmann <tobias@stoeckmann.org> Cc: Serge Hallyn <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
ad307ee42a
commit
f22ca217cd
@@ -76,17 +76,21 @@ static bool is_valid_name (const char *name)
|
||||
bool
|
||||
is_valid_user_name(const char *name)
|
||||
{
|
||||
long maxsize;
|
||||
long conf;
|
||||
size_t maxsize;
|
||||
|
||||
errno = 0;
|
||||
maxsize = sysconf(_SC_LOGIN_NAME_MAX);
|
||||
if (maxsize == -1 && errno != 0)
|
||||
maxsize = LOGIN_NAME_MAX;
|
||||
conf = sysconf(_SC_LOGIN_NAME_MAX);
|
||||
|
||||
if (strlen(name) >= (size_t)maxsize)
|
||||
if (conf == -1 && errno != 0)
|
||||
maxsize = LOGIN_NAME_MAX;
|
||||
else
|
||||
maxsize = conf;
|
||||
|
||||
if (strlen(name) >= maxsize)
|
||||
return false;
|
||||
|
||||
return is_valid_name (name);
|
||||
return is_valid_name(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user