From 91d3057085a04ea2342dc8fc4fb92a3676fd7566 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 29 Mar 2011 10:46:04 +0000 Subject: [PATCH] * uinfo.cc (cygheap_user::env_domain): Use LookupAccountSidW and convert user and domain to multibyte strings to make sure to use correct codeset. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/uinfo.cc | 18 +++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8518b9906..459b6bb2f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2011-03-29 Corinna Vinschen + + * uinfo.cc (cygheap_user::env_domain): Use LookupAccountSidW and + convert user and domain to multibyte strings to make sure to use + correct codeset. + 2011-03-29 Corinna Vinschen * autoload.cc (UuidCreate): Remove. diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 60db38e76..66cab121e 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -1,7 +1,7 @@ /* uinfo.cc: user info (uid, gid, etc...) Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008 Red Hat, Inc. + 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. This file is part of Cygwin. @@ -382,21 +382,21 @@ cygheap_user::env_domain (const char *name, size_t namelen) if (pwinname && test_uid (pdomain, name, namelen)) return pdomain; - char username[UNLEN + 1]; - DWORD ulen = sizeof (username); - char userdomain[DNLEN + 1]; - DWORD dlen = sizeof (userdomain); + DWORD ulen = UNLEN + 1; + WCHAR username[ulen]; + DWORD dlen = DNLEN + 1; + WCHAR userdomain[dlen]; SID_NAME_USE use; cfree_and_set (pwinname, almost_null); cfree_and_set (pdomain, almost_null); - if (!LookupAccountSid (NULL, sid (), username, &ulen, - userdomain, &dlen, &use)) + if (!LookupAccountSidW (NULL, sid (), username, &ulen, + userdomain, &dlen, &use)) __seterrno (); else { - pwinname = cstrdup (username); - pdomain = cstrdup (userdomain); + sys_wcstombs_alloc (&pwinname, HEAP_STR, username); + sys_wcstombs_alloc (&pdomain, HEAP_STR, userdomain); } return pdomain; }