From: Alejandro Colomar Date: Mon, 5 Feb 2024 12:44:52 +0000 (+0100) Subject: lib/: Don't say 'len' where 'size' is meant X-Git-Tag: 4.15.0-rc2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=51cd6aec021e8c71ca7400bee39af41bf24d6634;p=thirdparty%2Fshadow.git lib/: Don't say 'len' where 'size' is meant Fixes: 45c6603cc86c ("[svn-upgrade] Integrating new upstream version, shadow (19990709)") Fixes: 3b7cc053872c ("lib: replace `USER_NAME_MAX_LENGTH` macro") Fixes: 6be85b0bafb5 ("lib/chkname.c: Use tmp variable to avoid a -Wsign-compare warning") See-also: 403a2e3771be ("lib/chkname.c: Take NUL byte into account") See-also: 6a1f45d932c8 ("lib/chkname.c: Support unlimited user name lengths") Fixes: 95ea61009da8 ("lib/chkname.c: Use precise comment") Reviewed-by: Iker Pedrosa Cc: Tobias Stoeckmann Cc: Serge Hallyn Signed-off-by: Alejandro Colomar --- diff --git a/lib/chkname.c b/lib/chkname.c index 27a809349..433eb5e69 100644 --- a/lib/chkname.c +++ b/lib/chkname.c @@ -76,16 +76,13 @@ static bool is_valid_name (const char *name) bool is_valid_user_name (const char *name) { - long maxlen; + long maxsize; - /* - * User name length should be limited by the kernel - */ errno = 0; - maxlen = sysconf(_SC_LOGIN_NAME_MAX); - if (maxlen == -1 && errno != 0) - maxlen = LOGIN_NAME_MAX; - if (maxlen != -1 && strlen(name) >= (size_t)maxlen) + maxsize = sysconf(_SC_LOGIN_NAME_MAX); + if (maxsize == -1 && errno != 0) + maxsize = LOGIN_NAME_MAX; + if (maxsize != -1 && strlen(name) >= (size_t)maxsize) return false; return is_valid_name (name); diff --git a/lib/prototypes.h b/lib/prototypes.h index 2fb38cd06..0fac291c6 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -365,8 +365,8 @@ unsigned long csrand_interval (unsigned long min, unsigned long max); extern int remove_tree (const char *root, bool remove_root); /* rlogin.c */ -extern int do_rlogin (const char *remote_host, char *name, size_t namelen, - char *term, size_t termlen); +extern int do_rlogin(const char *remote_host, char *name, size_t namesize, + char *term, size_t termsize); /* root_flag.c */ extern void process_root_flag (const char* short_opt, int argc, char **argv); diff --git a/lib/rlogin.c b/lib/rlogin.c index 0a48668da..c2b899eb3 100644 --- a/lib/rlogin.c +++ b/lib/rlogin.c @@ -41,7 +41,9 @@ static struct { { -1, -1} }; -static void get_remote_string (char *buf, size_t size) + +static void +get_remote_string(char *buf, size_t size) { for (;;) { if (read (0, buf, 1) != 1) { @@ -55,11 +57,13 @@ static void get_remote_string (char *buf, size_t size) ++buf; } } - /*NOTREACHED*/} + /*NOTREACHED*/ +} + int -do_rlogin (const char *remote_host, char *name, size_t namelen, char *term, - size_t termlen) +do_rlogin(const char *remote_host, char *name, size_t namesize, char *term, + size_t termsize) { struct passwd *pwd; char remote_name[32]; @@ -69,9 +73,9 @@ do_rlogin (const char *remote_host, char *name, size_t namelen, char *term, int i; TERMIO termio; - get_remote_string (remote_name, sizeof remote_name); - get_remote_string (name, namelen); - get_remote_string (term, termlen); + get_remote_string(remote_name, sizeof(remote_name)); + get_remote_string(name, namesize); + get_remote_string(term, termsize); cp = strchr (term, '/'); if (NULL != cp) { @@ -126,4 +130,3 @@ do_rlogin (const char *remote_host, char *name, size_t namelen, char *term, #endif } #endif /* RLOGIN */ -