]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/limits.c: check_logins(): Report LOGIN_ERROR_LOGIN if str2ul() ERANGE
authorAlejandro Colomar <alx@kernel.org>
Thu, 11 Jan 2024 10:47:50 +0000 (11:47 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 12 Jul 2024 03:42:58 +0000 (22:42 -0500)
Fixes: 10396f953613 ("* libmisc/limits.c: Parse the limits, umask, nice, maxlogin, file limit with getlog() / getulong().")
Link: <https://github.com/shadow-maint/shadow/pull/893/commits/882cf59459bc4501b0882a7f02d36c8ce28a30f2>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/limits.c

index 6c1a97f634b87e0050f7ff3c1fcf2faa753f9bb4..fe0e24db716226a2d591c8c2239f4a608777b12a 100644 (file)
@@ -118,6 +118,10 @@ static int check_logins (const char *name, const char *maxlogins)
        unsigned long limit, count;
 
        if (str2ul(&limit, maxlogins) == -1) {
+               if (errno == ERANGE) {
+                       SYSLOG((LOG_WARN, "Invalid maxlogins value\n"));
+                       return LOGIN_ERROR_LOGIN;
+               }
                return 0;
        }