*********************************************************/
#define GROUP_STRING_SIZE 16384
+#define GROUP_MAX_COUNT (GROUP_STRING_SIZE / (10 + 1))
/**
* This function exports all the IDs of the current user so if
snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->sgid);
setenv("UID_WRAPPER_INITIAL_SGID", unsigned_str, 1);
+ if (id->ngroups > GROUP_MAX_COUNT) {
+ UWRAP_LOG(UWRAP_LOG_ERROR,
+ "ERROR: Number of groups (%u) exceeds maximum value "
+ "uid_wrapper will handle (%u).",
+ id->ngroups,
+ GROUP_MAX_COUNT);
+ exit(-1);
+ }
+
/* GROUPS */
snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->ngroups);
setenv("UID_WRAPPER_INITIAL_GROUPS_COUNT", unsigned_str, 1);
unsetenv("UID_WRAPPER_INITIAL_GROUPS_COUNT");
}
- if (ngroups > 0) {
+ if (ngroups > 0 && ngroups < GROUP_MAX_COUNT) {
int i = 0;
id->ngroups = 0;