From 838cfa352cf0d7146976af5548866393aeeb8862 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 9 Jan 2017 14:02:19 +0100 Subject: [PATCH] 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 --- winsup/cygwin/sec_auth.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/sec_auth.cc b/winsup/cygwin/sec_auth.cc index 50823c613..d4c2701da 100644 --- a/winsup/cygwin/sec_auth.cc +++ b/winsup/cygwin/sec_auth.cc @@ -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)