aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/grp.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-04-01 13:15:18 +0200
committerCorinna Vinschen <corinna@vinschen.de>2015-04-23 21:57:09 +0200
commit71a897e40d4a9f0b3a6caf6bae974c00aae2cbe8 (patch)
tree7eedac7d143e6ad2f15ba7b7e1783f3676a3d975 /winsup/cygwin/grp.cc
parentadbc3d4bb19771950a0c471cf5303f9f55dc9b4d (diff)
downloadnewlib-71a897e40d4a9f0b3a6caf6bae974c00aae2cbe8.zip
newlib-71a897e40d4a9f0b3a6caf6bae974c00aae2cbe8.tar.gz
newlib-71a897e40d4a9f0b3a6caf6bae974c00aae2cbe8.tar.bz2
Avoid potential crash at startup or in getgroups(2).
* grp.cc (internal_getgroups): Handle negative domain index to avoid crashes. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r--winsup/cygwin/grp.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index ea20e92..40e1ca7 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -643,13 +643,17 @@ internal_getgroups (int gidsetsize, gid_t *grouplist, cyg_ldap *pldap)
{
for (ULONG ncnt = 0; ncnt < scnt; ++ncnt)
{
+ static UNICODE_STRING empty = { 0, 0, (PWSTR) L"" };
fetch_acc_t full_acc =
{
.sid = sidp_buf[ncnt],
.name = &nlst[ncnt].Name,
- .dom = &dlst->Domains[nlst[ncnt].DomainIndex].Name,
+ .dom = &empty,
.acc_type = nlst[ncnt].Use
};
+
+ if (nlst[ncnt].DomainIndex >= 0)
+ full_acc.dom = &dlst->Domains[nlst[ncnt].DomainIndex].Name;
if ((grp = internal_getgrfull (full_acc, pldap)))
{
if (cnt < gidsetsize)