selinux/libsepol
Nicolas Iooss b251dbba98 libsepol: fix use-after-free in sepol_user_clone()
When sepol_user_add_role() fails to allocate memory for role_cp but
succeeds in reallocating user->roles memory, it frees this reallocated
memory, thus leaving user->roles referencing a free memory block. When
sepol_user_clone() calls sepol_user_free(new_user) because the
allocation failure made sepol_user_add_role() fail, the following code
is executed:

    for (i = 0; i < user->num_roles; i++)
        free(user->roles[i]);
    free(user->roles);

As user->roles has been freed, this code frees pointers which may be
invalid and then tries to free user->roles again.

Fix this flaw by returning right after strdup() failed in
sepol_user_add_role().

This issue has been found using clang's static analyzer.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-03-29 10:26:47 -04:00
..
cil libsepol/cil: Add hexadecimal support for Xen ioportcon statements 2017-03-28 13:33:05 -04:00
include libsepol: constify sepol_genbools()'s boolpath parameter 2017-03-29 10:26:44 -04:00
man libsepol: constify sepol_genbools()'s boolpath parameter 2017-03-29 10:26:44 -04:00
src libsepol: fix use-after-free in sepol_user_clone() 2017-03-29 10:26:47 -04:00
tests libsepol/tests: fix -Wwrite-strings warnings 2017-02-06 11:06:04 -05:00
utils libsepol: Android/MacOS X build support 2012-06-28 11:21:15 -04:00
.gitignore libsepol: build cil into libsepol 2014-08-26 08:03:31 -04:00
COPYING initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
Makefile libsepol: build cil into libsepol 2014-08-26 08:03:31 -04:00
VERSION Update VERSION and ChangeLog files for 2.6 final release. 2016-10-14 11:31:26 -04:00