2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

Fix off by one error when allocating user_groups.

This commit is contained in:
Todd C. Miller
2010-03-23 05:21:38 -04:00
parent 0ea0d60cbd
commit eae881b5aa

View File

@@ -1237,12 +1237,14 @@ deserialize_info(char * const settings[], char * const user_info[])
/* Count number of groups */
const char *val = *cur + sizeof("groups=") - 1;
const char *cp;
for (cp = val; *cp != '\0'; cp++) {
if (*cp == ',')
user_ngroups++;
}
if (user_ngroups) {
user_groups = emalloc2(user_ngroups, sizeof(gid_t));
if (val[0] != '\0') {
user_ngroups = 1;
for (cp = val; *cp != '\0'; cp++) {
if (*cp == ',')
user_ngroups++;
}
user_groups = emalloc2(user_ngroups, sizeof(GETGROUPS_T));
user_ngroups = 0;
cp = val;
for (;;) {