diff options
author | Egor Duda <deo@logos-m.ru> | 2001-04-11 13:38:55 +0400 |
---|---|---|
committer | Egor Duda <deo@logos-m.ru> | 2001-04-11 13:38:55 +0400 |
commit | dd9752e88e985b1ec7ec4a2cb4f3b276f5d35abb (patch) | |
tree | f11d8c837c2832056bda20509d8a044ab6ea29f9 /winsup/utils/mkpasswd.c | |
parent | 619f7fa0324c0eecdb7d32c5721c46b7d9a7f80b (diff) |
* mkgroup.c (uni2ansi): Use native method to convert from Unicode
to multi-byte strings.
* mkpasswd.c (uni2ansi): Ditto.
(enum_users): Pass buffer size when converting string.
(enum_local_groups): Ditto.
* mkgroup.c (enum_groups): Ditto.
(enum_local_groups): Ditto.
Diffstat (limited to 'winsup/utils/mkpasswd.c')
-rw-r--r-- | winsup/utils/mkpasswd.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/winsup/utils/mkpasswd.c b/winsup/utils/mkpasswd.c index 47d344038..1309cac4d 100644 --- a/winsup/utils/mkpasswd.c +++ b/winsup/utils/mkpasswd.c @@ -92,11 +92,10 @@ psx_dir (char *in, char *out) } void -uni2ansi (LPWSTR wcs, char *mbs) +uni2ansi (LPWSTR wcs, char *mbs, int size) { if (wcs) - wcstombs (mbs, wcs, (wcslen (wcs) + 1) * sizeof (WCHAR)); - + WideCharToMultiByte (CP_ACP, 0, wcs, -1, mbs, size, NULL, NULL); else *mbs = '\0'; } @@ -113,7 +112,7 @@ enum_users (LPWSTR servername, int print_sids, int print_cygpath, char ansi_srvname[256]; if (servername) - uni2ansi (servername, ansi_srvname); + uni2ansi (servername, ansi_srvname, sizeof (ansi_srvname)); do { @@ -152,10 +151,10 @@ enum_users (LPWSTR servername, int print_sids, int print_cygpath, int uid = buffer[i].usri3_user_id; int gid = buffer[i].usri3_primary_group_id; - uni2ansi (buffer[i].usri3_name, username); - uni2ansi (buffer[i].usri3_full_name, fullname); + uni2ansi (buffer[i].usri3_name, username, sizeof (username)); + uni2ansi (buffer[i].usri3_full_name, fullname, sizeof (fullname)); homedir_w32[0] = homedir_psx[0] = '\0'; - uni2ansi (buffer[i].usri3_home_dir, homedir_w32); + uni2ansi (buffer[i].usri3_home_dir, homedir_w32, sizeof (homedir_w32)); if (print_cygpath) cygwin_conv_to_posix_path (homedir_w32, homedir_psx); else @@ -264,7 +263,7 @@ enum_local_groups (int print_sids) DWORD sid_length = 1024; DWORD gid; SID_NAME_USE acc_type; - uni2ansi (buffer[i].lgrpi0_name, localgroup_name); + uni2ansi (buffer[i].lgrpi0_name, localgroup_name, sizeof (localgroup_name)); if (!LookupAccountName (NULL, localgroup_name, psid, &sid_length, domain_name, &domname_len, |