Corinna,

Sorry, I just noticed a handle leak in internal_getgroups
(change of 2003/1/17). It only happens when called from the
new function in the patch I just sent. It's a two line fix,
with a lot of whitespace changes. 

Pierre

2003/02/04  Pierre Humblet  <[EMAIL PROTECTED]>
 
        * grp.cc (internal_getgroups): Do not return without closing
        the process handle.
Index: grp.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/grp.cc,v
retrieving revision 1.75
diff -u -p -r1.75 grp.cc
--- grp.cc      4 Feb 2003 14:58:04 -0000       1.75
+++ grp.cc      4 Feb 2003 16:26:55 -0000
@@ -263,27 +263,28 @@ internal_getgroups (int gidsetsize, __gi
              if (srchsid)
                {
                  for (DWORD pg = 0; pg < groups->GroupCount; ++pg)
-                   if (*srchsid == groups->Groups[pg].Sid)
-                     return 1;
-                 return 0;
+                   if ((cnt = (*srchsid == groups->Groups[pg].Sid)))
+                     break;
+                 cnt = -1;
                }
-             for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
-               if (sid.getfromgr (gr))
-                 for (DWORD pg = 0; pg < groups->GroupCount; ++pg)
-                   if (sid == groups->Groups[pg].Sid &&
-                       sid != well_known_world_sid)
-                     {
-                       if (cnt < gidsetsize)
-                         grouplist[cnt] = gr->gr_gid;
-                       ++cnt;
-                       if (gidsetsize && cnt > gidsetsize)
-                         {
-                           if (hToken != cygheap->user.token)
-                             CloseHandle (hToken);
-                           goto error;
-                         }
-                       break;
-                     }
+             else
+               for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
+                 if (sid.getfromgr (gr))
+                   for (DWORD pg = 0; pg < groups->GroupCount; ++pg)
+                     if (sid == groups->Groups[pg].Sid &&
+                         sid != well_known_world_sid)
+                       {
+                         if (cnt < gidsetsize)
+                           grouplist[cnt] = gr->gr_gid;
+                         ++cnt;
+                         if (gidsetsize && cnt > gidsetsize)
+                           {
+                             if (hToken != cygheap->user.token)
+                               CloseHandle (hToken);
+                             goto error;
+                           }
+                         break;
+                       }
            }
        }
       else

Reply via email to