Avoid possible malloc(0) if plugin returns an empty groups list.

This commit is contained in:
Todd C. Miller
2010-05-20 17:10:16 -04:00
parent 9360e67a3d
commit 20c125297f

View File

@@ -494,7 +494,9 @@ command_info_to_details(char * const info[], struct command_details *details)
break;
cp++;
}
details->groups = emalloc2(details->ngroups, sizeof(GETGROUPS_T));
if (details->ngroups != 0) {
details->groups =
emalloc2(details->ngroups, sizeof(GETGROUPS_T));
cp = info[i] + sizeof("runas_groups=") - 1;
for (j = 0; j < details->ngroups;) {
errno = 0;
@@ -507,6 +509,7 @@ command_info_to_details(char * const info[], struct command_details *details)
cp = ep + 1;
}
details->ngroups = j;
}
break;
}
if (strncmp("runas_uid=", info[i], sizeof("runas_uid=") - 1) == 0) {