Handle sudo_get_grlist() returning NULL which can happen if

getgrouplist() fails even after allocating the appropriate amount
of memory.  From Stephane Chazelas
This commit is contained in:
Todd C. Miller
2015-02-05 11:17:24 -07:00
parent 6d71b488b6
commit b727d4309c

View File

@@ -1589,9 +1589,11 @@ runas_setgroups(void)
#ifdef HAVE_SETAUTHDB #ifdef HAVE_SETAUTHDB
aix_restoreauthdb(); aix_restoreauthdb();
#endif #endif
if (sudo_setgroups(grlist->ngids, grlist->gids) < 0) { if (grlist != NULL) {
sudo_grlist_delref(grlist); if (sudo_setgroups(grlist->ngids, grlist->gids) < 0) {
grlist = NULL; sudo_grlist_delref(grlist);
grlist = NULL;
}
} }
debug_return_ptr(grlist); debug_return_ptr(grlist);
} }