]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
usermod: Check sysconf return value
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 11 Mar 2026 21:35:22 +0000 (22:35 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Fri, 13 Mar 2026 20:15:39 +0000 (21:15 +0100)
Verify that sysconf does not return -1. It is not important if it's due
to an error or due to a missing upper boundary. In both cases, fall back
to a constant value.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/usermod.c

index 2c4651f1b77b6c6df8d61f46ed4c5d513a8eb9cb..af66d38c022cfa6b409a099774af5f3cf5d30e84 100644 (file)
 /* invalid shadow time indicating missing entry */
 #define MISSING_TIME   -2
 
+#ifndef NGROUPS_MAX
+#define NGROUPS_MAX            65536
+#endif
+
 /*
  * Structures
  */
@@ -2203,6 +2207,8 @@ int main (int argc, char **argv)
 #endif
 
        sys_ngroups = sysconf (_SC_NGROUPS_MAX);
+       if (sys_ngroups == -1)
+               sys_ngroups = NGROUPS_MAX;
        user_groups = xmalloc_T(sys_ngroups + 1, char *);
        user_groups[0] = NULL;