This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] Don't free statically allocated sys_privs


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=838cfa352cf0d7146976af5548866393aeeb8862

commit 838cfa352cf0d7146976af5548866393aeeb8862
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Mon Jan 9 14:02:19 2017 +0100

    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>

Diff:
---
 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 50823c6..d4c2701 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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]