]> granicus.if.org Git - sudo/commitdiff
Make sure groupname_len is at least 32 just to be on the safe side.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 5 Mar 2013 19:06:51 +0000 (14:06 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 5 Mar 2013 19:06:51 +0000 (14:06 -0500)
It is better to allocate a little extra and not need it than to
have to reallocate and start over.

plugins/sudoers/pwutil_impl.c

index 5c3994ae81d838ff0addbfc0897edcd889a3ec7a..fb77d931c4694282489f5c47a8d85b032b8befe0 100644 (file)
@@ -271,10 +271,10 @@ sudo_make_grlist_item(struct passwd *pw)
 #endif
 
 #if defined(HAVE_SYSCONF) && defined(_SC_LOGIN_NAME_MAX)
-    groupname_len = (int)sysconf(_SC_LOGIN_NAME_MAX);
-    if (groupname_len < 0)
+    groupname_len = MAX((int)sysconf(_SC_LOGIN_NAME_MAX), 32);
+#else
+    groupname_len = MAX(LOGIN_NAME_MAX, 32);
 #endif
-       groupname_len = LOGIN_NAME_MAX;
 
     /* Allocate in one big chunk for easy freeing. */
     nsize = strlen(pw->pw_name) + 1;