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

commit 0e3fd33321414e03466370bca048b4c4b6f91ba0
Author: Corinna Vinschen <[email protected]>
Date:   Fri Jan 25 19:58:21 2019 +0100

    Cygwin: create_token: Return NULL, not  INVALID_HANDLE_VALUE
    
    Signed-off-by: Corinna Vinschen <[email protected]>

Diff:
---
 winsup/cygwin/sec_auth.cc | 5 +++--
 winsup/cygwin/syscalls.cc | 5 ++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/winsup/cygwin/sec_auth.cc b/winsup/cygwin/sec_auth.cc
index 1d07e37..54053df 100644
--- a/winsup/cygwin/sec_auth.cc
+++ b/winsup/cygwin/sec_auth.cc
@@ -907,8 +907,8 @@ create_token (cygsid &usersid, user_groups &new_groups)
   source.SourceIdentifier.HighPart = 0;
   source.SourceIdentifier.LowPart = 0x0101;
 
-  HANDLE token = INVALID_HANDLE_VALUE;
-  HANDLE primary_token = INVALID_HANDLE_VALUE;
+  HANDLE token = NULL;
+  HANDLE primary_token = NULL;
 
   tmp_pathbuf tp;
   PTOKEN_GROUPS my_tok_gsids = NULL;
@@ -1010,6 +1010,7 @@ create_token (cygsid &usersid, user_groups &new_groups)
        {
          __seterrno ();
          debug_printf ("DuplicateTokenEx %E");
+         primary_token = NULL;
        }
     }
 
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 289f462..978bd42 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3546,10 +3546,9 @@ seteuid32 (uid_t uid)
          if (!(new_token = lsaauth (usersid, groups)))
            {
              debug_printf ("lsaauth failed, try create_token.");
-             new_token = create_token (usersid, groups);
-             if (new_token == INVALID_HANDLE_VALUE)
+             if (!(new_token = create_token (usersid, groups)))
                {
-                 debug_printf ("create_token failed, bail out of here");
+                 debug_printf ("create_token failed, bail out");
                  cygheap->user.reimpersonate ();
                  return -1;
                }

Reply via email to