Don't free statically allocated sys_privs

commit 67fd2101 introduced a bad bug.  Changing sys_privs to a static
area and just returning a pointer is nice... *if* the calling code doesn't
call free() on it.  Make sure callers check pointer for sys_privs and
refrain from calling free, if so.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2017-01-09 14:02:19 +01:00
parent 61f181d6b8
commit 838cfa352c
1 changed files with 2 additions and 2 deletions

View File

@ -993,7 +993,7 @@ out:
pop_self_privilege ();
if (token != INVALID_HANDLE_VALUE)
CloseHandle (token);
if (privs)
if (privs && privs != (PTOKEN_PRIVILEGES) &sys_privs)
free (privs);
lsa_close_policy (lsa);
@ -1229,7 +1229,7 @@ lsaauth (cygsid &usersid, user_groups &new_groups)
user_token = get_full_privileged_inheritable_token (user_token);
out:
if (privs)
if (privs && privs != (PTOKEN_PRIVILEGES) &sys_privs)
free (privs);
lsa_close_policy (lsa);
if (lsa_hdl)