Skip to content

Commit

Permalink
src/login.c: main(): Use login_name_max_size()
Browse files Browse the repository at this point in the history
Instead of raw sysconf(_SC_LOGIN_NAME_MAX) calls, which was being used
without error handling.

Fixes: 3b7cc05 ("lib: replace `USER_NAME_MAX_LENGTH` macro")
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar authored and ikerexxe committed May 21, 2024
1 parent 99df9d7 commit a6eb312
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "alloc.h"
#include "attr.h"
#include "chkname.h"
#include "defines.h"
#include "faillog.h"
#include "failure.h"
Expand Down Expand Up @@ -573,8 +574,9 @@ int main (int argc, char **argv)
}
#ifdef RLOGIN
if (rflg) {
size_t max_size = sysconf(_SC_LOGIN_NAME_MAX);
size_t max_size;

max_size = login_name_max_size();
assert (NULL == username);
username = XMALLOC(max_size, char);
username[max_size - 1] = '\0';
Expand Down Expand Up @@ -882,8 +884,9 @@ int main (int argc, char **argv)

failed = false; /* haven't failed authentication yet */
if (NULL == username) { /* need to get a login id */
size_t max_size = sysconf(_SC_LOGIN_NAME_MAX);
size_t max_size;

max_size = login_name_max_size();
if (subroot) {
closelog ();
exit (1);
Expand Down

0 comments on commit a6eb312

Please sign in to comment.