From a6eb312f60a5c0e11483ead2fb1635f282da8e59 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Tue, 14 May 2024 01:13:18 +0200 Subject: [PATCH] src/login.c: main(): Use login_name_max_size() Instead of raw sysconf(_SC_LOGIN_NAME_MAX) calls, which was being used without error handling. Fixes: 3b7cc053872c ("lib: replace `USER_NAME_MAX_LENGTH` macro") Signed-off-by: Alejandro Colomar --- src/login.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/login.c b/src/login.c index a862c6bd..9fed7b38 100644 --- a/src/login.c +++ b/src/login.c @@ -27,6 +27,7 @@ #include "alloc.h" #include "attr.h" +#include "chkname.h" #include "defines.h" #include "faillog.h" #include "failure.h" @@ -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'; @@ -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);