From 71a897e40d4a9f0b3a6caf6bae974c00aae2cbe8 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 1 Apr 2015 13:15:18 +0200 Subject: 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 --- winsup/cygwin/grp.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'winsup/cygwin/grp.cc') diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index ea20e926c..40e1ca763 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) -- cgit v1.2.3