Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Humblet <phumblet@phumblet.no-ip.org>2003-07-18 06:14:42 +0400
committerPierre Humblet <phumblet@phumblet.no-ip.org>2003-07-18 06:14:42 +0400
commitb4ece40c0f9600c19261f1776855940780a140c1 (patch)
tree9bcdf10036c16409ebef093b1f4799ca3c46a6c6
parent19c6e1624bc4c6b5d4757a173671a52fc0484248 (diff)
2003-07-18 Pierre Humblet <pierre.humblet@ieee.org>
* security.cc (verify_token): Fix white space and style. Use type bool instead of BOOL and char. Use alloca instead of malloc and free for my_grps.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/security.cc39
2 files changed, 22 insertions, 23 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c18ad1438..5c8f35e5c 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2003-07-18 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * security.cc (verify_token): Fix white space and style.
+ Use type bool instead of BOOL and char. Use alloca
+ instead of malloc and free for my_grps.
+
2003-07-17 Corinna Vinschen <corinna@vinschen.de>
* sysconf.cc (sysconf): Fix OPEN_MAX patch. Return page size on
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index 7f7d9d1bd..0310f5c8b 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -744,30 +744,26 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, BOOL *pintern)
return gsid == groups.pgsid;
}
- PTOKEN_GROUPS my_grps = NULL;
- BOOL ret = FALSE;
- char saw_buf[NGROUPS_MAX] = {};
- char *saw = saw_buf, sawpg = FALSE;
+ PTOKEN_GROUPS my_grps;
+ bool saw_buf[NGROUPS_MAX] = {};
+ bool *saw = saw_buf, sawpg = false, ret = false;
if (!GetTokenInformation (token, TokenGroups, NULL, 0, &size) &&
GetLastError () != ERROR_INSUFFICIENT_BUFFER)
debug_printf ("GetTokenInformation(token, TokenGroups): %E");
- else if (!(my_grps = (PTOKEN_GROUPS) malloc (size)))
- debug_printf ("malloc (my_grps) failed.");
+ else if (!(my_grps = (PTOKEN_GROUPS) alloca (size)))
+ debug_printf ("alloca (my_grps) failed.");
else if (!GetTokenInformation (token, TokenGroups, my_grps, size, &size))
debug_printf ("GetTokenInformation(my_token, TokenGroups): %E");
else if (!groups.issetgroups ()) /* setgroups was never called */
- {
- ret = sid_in_token_groups (my_grps, groups.pgsid);
- if (ret == FALSE)
- ret = (groups.pgsid == tok_usersid);
- }
+ ret = sid_in_token_groups (my_grps, groups.pgsid)
+ || groups.pgsid == usersid;
else /* setgroups was called */
{
struct __group32 *gr;
cygsid gsid;
- if (groups.sgsids.count > (int) sizeof (saw_buf) &&
- !(saw = (char *) calloc (groups.sgsids.count, sizeof (char))))
+ if (groups.sgsids.count > (int) (sizeof (saw_buf) / sizeof (*saw_buf))
+ && !(saw = (bool *) calloc (groups.sgsids.count, sizeof (bool))))
goto done;
/* token groups found in /etc/group match the user.gsids ? */
@@ -776,24 +772,21 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, BOOL *pintern)
{
int pos = groups.sgsids.position (gsid);
if (pos >= 0)
- saw[pos] = TRUE;
+ saw[pos] = true;
else if (groups.pgsid == gsid)
- sawpg = TRUE;
- else if (gsid != well_known_world_sid &&
- gsid != usersid)
+ sawpg = true;
+ else if (gsid != well_known_world_sid
+ && gsid != usersid)
goto done;
}
for (int gidx = 0; gidx < groups.sgsids.count; gidx++)
if (!saw[gidx])
goto done;
- if (sawpg ||
- groups.sgsids.contains (groups.pgsid) ||
- groups.pgsid == usersid)
- ret = TRUE;
+ ret = sawpg
+ || groups.sgsids.contains (groups.pgsid)
+ || groups.pgsid == usersid;
}
done:
- if (my_grps)
- free (my_grps);
if (saw != saw_buf)
free (saw);
return ret;