OSDN Git Service

* security.cc (subauth): Initialize user_token to NULL. Add comment.
authorcorinna <corinna>
Mon, 14 Aug 2006 11:32:10 +0000 (11:32 +0000)
committercorinna <corinna>
Mon, 14 Aug 2006 11:32:10 +0000 (11:32 +0000)
winsup/cygwin/ChangeLog
winsup/cygwin/security.cc

index 857f1e7..156f661 100644 (file)
@@ -1,3 +1,7 @@
+2006-08-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * security.cc (subauth): Initialize user_token to NULL.  Add comment.
+
 2006-08-11  Corinna Vinschen  <corinna@vinschen.de>
 
        * shared.cc (open_shared): Desperately try to get shared memory, only
index d435f30..618a57e 100644 (file)
@@ -1009,7 +1009,10 @@ subauth (struct passwd *pw)
   QUOTA_LIMITS quota;
   char nt_domain[INTERNET_MAX_HOST_NAME_LENGTH + 1];
   char nt_user[UNLEN + 1];
-  HANDLE user_token = INVALID_HANDLE_VALUE;
+  /* Changed from INVALID_HANDLE_VALUE to NULL.  A failed LsaLogonUser
+     sets the token to NULL anyway, so starting with NULL simplifies
+     the below test before calling CloseHandle. */
+  HANDLE user_token = NULL;
   HANDLE primary_token = INVALID_HANDLE_VALUE;
 
   push_self_privilege (SE_TCB_PRIV, true);
@@ -1076,7 +1079,7 @@ subauth (struct passwd *pw)
 
 out:
   pop_self_privilege ();
-  if (user_token != INVALID_HANDLE_VALUE)
+  if (user_token)
     CloseHandle (user_token);
   return primary_token;
 }