From: Todd C. Miller Date: Tue, 5 Mar 2013 19:06:51 +0000 (-0500) Subject: Make sure groupname_len is at least 32 just to be on the safe side. X-Git-Tag: SUDO_1_8_7~1^2~187 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=593832152fb3b200b58436b1f190e879ba1fb368;p=sudo Make sure groupname_len is at least 32 just to be on the safe side. It is better to allocate a little extra and not need it than to have to reallocate and start over. --- diff --git a/plugins/sudoers/pwutil_impl.c b/plugins/sudoers/pwutil_impl.c index 5c3994ae8..fb77d931c 100644 --- a/plugins/sudoers/pwutil_impl.c +++ b/plugins/sudoers/pwutil_impl.c @@ -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;