libsemanage: genhomedircon: double free in get_home_dirs

Right before the call to semanage_list_sort() we do some cleanup.
Including endpwent(); free(rbuf); semanage_list_destroy(&shells);  If
the call to the list sort fails we will go to fail: and will do those
cleanups a second time.  Whoops.  Do the list sort before the generic
cleanups so the failure code isn't run after the default cleanup.

Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
Eric Paris 2013-02-05 14:15:56 -05:00
parent d0c7f6ea4f
commit e1400f0404

View File

@ -401,11 +401,13 @@ static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s)
WARN(s->h_semanage, "Error while fetching users. "
"Returning list so far.");
}
if (semanage_list_sort(&homedir_list))
goto fail;
endpwent();
free(rbuf);
semanage_list_destroy(&shells);
if (semanage_list_sort(&homedir_list))
goto fail;
return homedir_list;