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:
authorCorinna Vinschen <corinna@vinschen.de>2008-02-14 19:47:11 +0300
committerCorinna Vinschen <corinna@vinschen.de>2008-02-14 19:47:11 +0300
commit7b4b41ab3e89bc6bde673b68107e378fa91b230d (patch)
tree1d1abbf7f5dddcc59dd7016a4356c828a81a7937
parentf16db7f54e3fb059e6875dc33ba66b64efbf33d7 (diff)
* cygheap.cc (cwcsdup): New function.
(cwcsdup1): New function. * cygheap.h (cygheap_user::get_windows_id): New method returning PWCHAR. (cwcsdup): Declare. (cwcsdup1): Declare. * registry.cc (get_registry_hive_path): Use WCHAR instead of char throughout. (load_registry_hive): Ditto. * registry.h (get_registry_hive_path): Change declaration accordingly. (load_registry_hive): Ditto. * sec_helper.cc (cygpsid::string): New method returning PWCHAR. * security.h (cygpsid::string): Declare. * syscalls.cc (seteuid32): Convert local name var to WCHAR. * uinfo.cc (cygheap_user::env_userprofile): Convert local name buffers to WCHAR. Call sys_wcstombs_alloc to generate puserprof buffer. * winsup.h: Fix comment. (NT_MAX_PATH): New definition for maximum internal path length. Use throughout where appropriate. * include/limits.h (PATH_MAX): Set to 4096 as on Linux.
-rw-r--r--winsup/cygwin/ChangeLog23
-rw-r--r--winsup/cygwin/cygheap.cc25
-rw-r--r--winsup/cygwin/cygheap.h10
-rw-r--r--winsup/cygwin/dcrt0.cc8
-rw-r--r--winsup/cygwin/dll_init.cc2
-rw-r--r--winsup/cygwin/dll_init.h2
-rw-r--r--winsup/cygwin/environ.cc4
-rw-r--r--winsup/cygwin/exceptions.cc6
-rw-r--r--winsup/cygwin/fhandler_process.cc8
-rw-r--r--winsup/cygwin/include/limits.h7
-rw-r--r--winsup/cygwin/include/sys/cygwin.h2
-rw-r--r--winsup/cygwin/path.cc10
-rw-r--r--winsup/cygwin/pinfo.cc10
-rw-r--r--winsup/cygwin/pinfo.h2
-rw-r--r--winsup/cygwin/registry.cc38
-rw-r--r--winsup/cygwin/registry.h4
-rw-r--r--winsup/cygwin/sec_helper.cc11
-rw-r--r--winsup/cygwin/security.h1
-rw-r--r--winsup/cygwin/smallprint.cc4
-rw-r--r--winsup/cygwin/strace.cc2
-rw-r--r--winsup/cygwin/syscalls.cc2
-rw-r--r--winsup/cygwin/uinfo.cc6
-rw-r--r--winsup/cygwin/winsup.h11
23 files changed, 138 insertions, 60 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 117cc10fd..bc0630ba4 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,26 @@
+2008-02-14 Corinna Vinschen <corinna@vinschen.de>
+
+ * cygheap.cc (cwcsdup): New function.
+ (cwcsdup1): New function.
+ * cygheap.h (cygheap_user::get_windows_id): New method returning PWCHAR.
+ (cwcsdup): Declare.
+ (cwcsdup1): Declare.
+ * registry.cc (get_registry_hive_path): Use WCHAR instead of char
+ throughout.
+ (load_registry_hive): Ditto.
+ * registry.h (get_registry_hive_path): Change declaration accordingly.
+ (load_registry_hive): Ditto.
+ * sec_helper.cc (cygpsid::string): New method returning PWCHAR.
+ * security.h (cygpsid::string): Declare.
+ * syscalls.cc (seteuid32): Convert local name var to WCHAR.
+ * uinfo.cc (cygheap_user::env_userprofile): Convert local name buffers
+ to WCHAR. Call sys_wcstombs_alloc to generate puserprof buffer.
+
+ * winsup.h: Fix comment.
+ (NT_MAX_PATH): New definition for maximum internal path length.
+ Use throughout where appropriate.
+ * include/limits.h (PATH_MAX): Set to 4096 as on Linux.
+
2008-02-13 Christopher Faylor <me+cygwin@cgf.cx>
* configure.in: Remove non-working options.
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index 23e193bc3..e3a2918b7 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -24,6 +24,7 @@
#include "sigproc.h"
#include "pinfo.h"
#include <unistd.h>
+#include <wchar.h>
init_cygheap NO_COPY *cygheap;
void NO_COPY *cygheap_max;
@@ -354,6 +355,30 @@ ccalloc_abort (cygheap_types x, DWORD n, DWORD size)
return ccalloc (x, n, size, "ccalloc");
}
+extern "C" PWCHAR __stdcall
+cwcsdup (const PWCHAR s)
+{
+ MALLOC_CHECK;
+ PWCHAR p = (PWCHAR) cmalloc (HEAP_STR, wcslen (s) + 1);
+ if (!p)
+ return NULL;
+ wcpcpy (p, s);
+ MALLOC_CHECK;
+ return p;
+}
+
+extern "C" PWCHAR __stdcall
+cwcsdup1 (const PWCHAR s)
+{
+ MALLOC_CHECK;
+ PWCHAR p = (PWCHAR) cmalloc (HEAP_1_STR, wcslen (s) + 1);
+ if (!p)
+ return NULL;
+ wcpcpy (p, s);
+ MALLOC_CHECK;
+ return p;
+}
+
extern "C" char *__stdcall
cstrdup (const char *s)
{
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 7d232584a..567aecf69 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -206,7 +206,11 @@ public:
if (internal_token != NO_IMPERSONATION)
CloseHandle (internal_token);
}
- char * get_windows_id (char * buf)
+ PWCHAR get_windows_id (PWCHAR buf)
+ {
+ return effec_cygsid.string (buf);
+ }
+ char *get_windows_id (char *buf)
{
return effec_cygsid.string (buf);
}
@@ -231,7 +235,7 @@ struct cwdstuff
DWORD get_drive (char * dst)
{
cwd_lock.acquire ();
- DWORD ret = sys_wcstombs (dst, PATH_MAX, win32.Buffer, drive_length);
+ DWORD ret = sys_wcstombs (dst, NT_MAX_PATH, win32.Buffer, drive_length);
cwd_lock.release ();
return ret;
}
@@ -423,6 +427,8 @@ void *__stdcall ccalloc (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3)
void *__stdcall cmalloc_abort (cygheap_types, DWORD) __attribute__ ((regparm(2)));
void *__stdcall crealloc_abort (void *, DWORD) __attribute__ ((regparm(2)));
void *__stdcall ccalloc_abort (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3)));
+PWCHAR __stdcall cwcsdup (const PWCHAR) __attribute__ ((regparm(1)));
+PWCHAR __stdcall cwcsdup1 (const PWCHAR) __attribute__ ((regparm(1)));
char *__stdcall cstrdup (const char *) __attribute__ ((regparm(1)));
char *__stdcall cstrdup1 (const char *) __attribute__ ((regparm(1)));
void __stdcall cfree_and_set (char *&, char * = NULL) __attribute__ ((regparm(2)));
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 0398388df..4ca329405 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -544,7 +544,7 @@ break_here ()
static void
initial_env ()
{
- char buf[PATH_MAX];
+ char buf[NT_MAX_PATH];
if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1))
_cygwin_testing = 1;
@@ -561,8 +561,8 @@ initial_env ()
}
if (GetEnvironmentVariable ("CYGWIN_DEBUG", buf, sizeof (buf) - 1))
{
- char buf1[PATH_MAX];
- len = GetModuleFileName (NULL, buf1, PATH_MAX);
+ char buf1[NT_MAX_PATH];
+ len = GetModuleFileName (NULL, buf1, NT_MAX_PATH);
strlwr (buf1);
strlwr (buf);
char *p = strpbrk (buf, ":=");
@@ -870,7 +870,7 @@ dll_crt0_1 (void *)
win32 style. */
if ((strchr (__argv[0], ':')) || (strchr (__argv[0], '\\')))
{
- char *new_argv0 = (char *) malloc (PATH_MAX);
+ char *new_argv0 = (char *) malloc (NT_MAX_PATH);
cygwin_conv_to_posix_path (__argv[0], new_argv0);
__argv[0] = (char *) realloc (new_argv0, strlen (new_argv0) + 1);
}
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index d76771216..3e143abc1 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -106,7 +106,7 @@ dll_list::operator[] (const char *name)
dll *
dll_list::alloc (HINSTANCE h, per_process *p, dll_type type)
{
- char name[PATH_MAX];
+ char name[NT_MAX_PATH];
DWORD namelen = GetModuleFileName (h, name, sizeof (name));
/* Already loaded? */
diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h
index cd88c564a..205123a2f 100644
--- a/winsup/cygwin/dll_init.h
+++ b/winsup/cygwin/dll_init.h
@@ -51,7 +51,7 @@ struct dll
int count;
dll_type type;
int namelen;
- char name[PATH_MAX];
+ char name[NT_MAX_PATH];
void detach ();
int init ();
};
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 3e0765bcf..a7c693168 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -116,7 +116,7 @@ win_env::add_cache (const char *in_posix, const char *in_native)
}
else
{
- char buf[PATH_MAX];
+ char buf[NT_MAX_PATH];
strcpy (buf, name + namelen);
towin32 (in_posix, buf);
native = (char *) realloc (native, namelen + 1 + strlen (buf));
@@ -185,7 +185,7 @@ posify (char **here, const char *value)
/* Turn all the items from c:<foo>;<bar> into their
mounted equivalents - if there is one. */
- char outenv[1 + len + PATH_MAX];
+ char outenv[1 + len + NT_MAX_PATH];
memcpy (outenv, src, len);
char *newvalue = outenv + len;
if (!conv->toposix (value, newvalue) || _impure_ptr->_errno != EIDRM)
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 05cc91696..73f6790dc 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -35,7 +35,7 @@ details. */
#define CALL_HANDLER_RETRY 20
-char debugger_command[2 * PATH_MAX + 20];
+char debugger_command[2 * NT_MAX_PATH + 20];
extern "C" {
extern void sigdelayed ();
@@ -118,8 +118,8 @@ error_start_init (const char *buf)
return;
}
- char pgm[PATH_MAX];
- if (!GetModuleFileName (NULL, pgm, PATH_MAX))
+ char pgm[NT_MAX_PATH];
+ if (!GetModuleFileName (NULL, pgm, NT_MAX_PATH))
strcpy (pgm, "cygwin1.dll");
for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\'))
*p = '/';
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index 380c25862..595488c99 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -442,7 +442,7 @@ fhandler_process::fill_filebuf ()
case PROCESS_EXENAME:
case PROCESS_EXE:
{
- filebuf = (char *) crealloc_abort (filebuf, bufalloc = PATH_MAX);
+ filebuf = (char *) crealloc_abort (filebuf, bufalloc = NT_MAX_PATH);
if (p->process_state & PID_EXITED)
strcpy (filebuf, "<defunct>");
else
@@ -524,8 +524,8 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize)
DWORD_PTR wset_size;
DWORD_PTR *workingset = NULL;
MODULEINFO info;
- WCHAR modname[PATH_MAX];
- char posix_modname[PATH_MAX];
+ WCHAR modname[NT_MAX_PATH];
+ char posix_modname[NT_MAX_PATH];
if (!EnumProcessModules (proc, NULL, 0, &needed))
{
@@ -557,7 +557,7 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize)
strcpy (access, "r--p");
struct __stat64 st;
if (mount_table->conv_to_posix_path (modname, posix_modname, 0))
- sys_wcstombs (posix_modname, PATH_MAX, modname);
+ sys_wcstombs (posix_modname, NT_MAX_PATH, modname);
if (stat64 (posix_modname, &st))
{
st.st_dev = 0;
diff --git a/winsup/cygwin/include/limits.h b/winsup/cygwin/include/limits.h
index e6e089da9..20dd84a0b 100644
--- a/winsup/cygwin/include/limits.h
+++ b/winsup/cygwin/include/limits.h
@@ -321,10 +321,11 @@ details. */
#undef NAME_MAX
#define NAME_MAX 255
-/* Maximum length of a path including trailing NUL.
- (32767 - max. native NT path prefix) */
+/* Maximum length of a path given to API functions including trailing NUL.
+ Deliberately set to the same default value as on Linux. Internal paths
+ may be longer. */
#undef PATH_MAX
-#define PATH_MAX 32760
+#define PATH_MAX 4096
/* # of bytes in a pipe buf. This is the max # of bytes which can be
written to a pipe in one atomic operation. */
diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h
index b8738fa70..287cc1db3 100644
--- a/winsup/cygwin/include/sys/cygwin.h
+++ b/winsup/cygwin/include/sys/cygwin.h
@@ -266,7 +266,7 @@ struct external_pinfo
__gid32_t gid32;
/* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */
- char progname_long[PATH_MAX];
+ char progname_long[NT_MAX_PATH];
};
#endif /*__CYGWIN__*/
#endif /*WINVER*/
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index e013d0b74..56ec17406 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2002,8 +2002,8 @@ mount_info::conv_to_posix_path (PWCHAR src_path, char *posix_path,
changed = true;
}
}
- char buf[PATH_MAX];
- sys_wcstombs (buf, PATH_MAX, src_path);
+ char buf[NT_MAX_PATH];
+ sys_wcstombs (buf, NT_MAX_PATH, src_path);
int ret = conv_to_posix_path (buf, posix_path, keep_rel_p);
if (changed)
src_path[0] = L'C';
@@ -4565,7 +4565,7 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit)
if (!posix_cwd)
{
- posix_cwd = (const char *) alloca (PATH_MAX);
+ posix_cwd = (const char *) alloca (NT_MAX_PATH);
mount_table->conv_to_posix_path (win32.Buffer, (char *) posix_cwd, 0);
}
posix = (char *) crealloc_abort (posix, strlen (posix_cwd) + 1);
@@ -4598,8 +4598,8 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen)
char *tocopy;
if (!need_posix)
{
- tocopy = (char *) alloca (PATH_MAX);
- sys_wcstombs (tocopy, PATH_MAX, win32.Buffer, win32.Length);
+ tocopy = (char *) alloca (NT_MAX_PATH);
+ sys_wcstombs (tocopy, NT_MAX_PATH, win32.Buffer, win32.Length);
}
else
tocopy = posix;
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index d1565f80d..632cc5f71 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -392,7 +392,7 @@ DWORD WINAPI
commune_process (void *arg)
{
siginfo_t& si = *((siginfo_t *) arg);
- char path[PATH_MAX];
+ char path[NT_MAX_PATH];
DWORD nr;
HANDLE& tothem = si._si_commune._si_write_handle;
HANDLE process_sync =
@@ -439,7 +439,7 @@ commune_process (void *arg)
case PICOM_CWD:
{
sigproc_printf ("processing PICOM_CWD");
- unsigned int n = strlen (cygheap->cwd.get (path, 1, 1, PATH_MAX)) + 1;
+ unsigned int n = strlen (cygheap->cwd.get (path, 1, 1, NT_MAX_PATH)) + 1;
if (!WriteFile (tothem, &n, sizeof n, &nr, NULL))
sigproc_printf ("WriteFile sizeof cwd failed, %E");
else if (!WriteFile (tothem, path, n, &nr, NULL))
@@ -665,7 +665,7 @@ _pinfo::fd (int fd, size_t &n)
if (cfd < 0)
s = cstrdup ("");
else
- s = cfd->get_proc_fd_name ((char *) cmalloc_abort (HEAP_COMMUNE, PATH_MAX));
+ s = cfd->get_proc_fd_name ((char *) cmalloc_abort (HEAP_COMMUNE, NT_MAX_PATH));
n = strlen (s) + 1;
}
return s;
@@ -736,8 +736,8 @@ _pinfo::cwd (size_t& n)
}
else
{
- s = (char *) cmalloc_abort (HEAP_COMMUNE, PATH_MAX);
- cygheap->cwd.get (s, 1, 1, PATH_MAX);
+ s = (char *) cmalloc_abort (HEAP_COMMUNE, NT_MAX_PATH);
+ cygheap->cwd.get (s, 1, 1, NT_MAX_PATH);
n = strlen (s) + 1;
}
return s;
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 3c5e100fb..18346fe83 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -64,7 +64,7 @@ public:
DWORD dwProcessId;
/* Used to spawn a child for fork(), among other things. */
- char progname[PATH_MAX];
+ char progname[NT_MAX_PATH];
/* User information.
The information is derived from the GetUserName system call,
diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc
index 3c67ff62f..93eb11386 100644
--- a/winsup/cygwin/registry.cc
+++ b/winsup/cygwin/registry.cc
@@ -19,6 +19,7 @@ details. */
#include "fhandler.h"
#include "dtable.h"
#include "cygheap.h"
+#include <wchar.h>
static const char cygnus_class[] = "cygnus";
reg_key::reg_key (HKEY top, REGSAM access, ...): _disposition (0)
@@ -207,54 +208,55 @@ reg_key::~reg_key ()
key_is_invalid = 1;
}
-char *
-get_registry_hive_path (const char *name, char *path)
+PWCHAR
+get_registry_hive_path (const PWCHAR name, PWCHAR path)
{
- char key[256];
+ WCHAR key[256], *kend;
HKEY hkey;
if (!name || !path)
return NULL;
- __small_sprintf (key, "SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\"
- "ProfileList\\%s", name);
- if (!RegOpenKeyExA (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hkey))
+ kend = wcpcpy (key, L"SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\ProfileList\\");
+ wcpcpy (kend, name);
+ if (!RegOpenKeyExW (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hkey))
{
- char buf[PATH_MAX];
+ WCHAR buf[NT_MAX_PATH];
+ WCHAR tmp[NT_MAX_PATH];
DWORD type, siz;
- path[0] = '\0';
- if (!RegQueryValueExA (hkey, "ProfileImagePath", 0, &type,
+ path[0] = L'\0';
+ if (!RegQueryValueExW (hkey, L"ProfileImagePath", 0, &type,
(BYTE *)buf, (siz = sizeof (buf), &siz)))
- ExpandEnvironmentStringsA (buf, path, PATH_MAX);
+ ExpandEnvironmentStringsW (buf, path, NT_MAX_PATH);
RegCloseKey (hkey);
if (path[0])
return path;
}
- debug_printf ("HKLM\\%s not found", key);
+ debug_printf ("HKLM\\%W not found", key);
return NULL;
}
void
-load_registry_hive (const char * name)
+load_registry_hive (const PWCHAR name)
{
- char path[PATH_MAX];
+ WCHAR path[NT_MAX_PATH];
HKEY hkey;
LONG ret;
if (!name)
return;
/* Check if user hive is already loaded. */
- if (!RegOpenKeyExA (HKEY_USERS, name, 0, KEY_READ, &hkey))
+ if (!RegOpenKeyExW (HKEY_USERS, name, 0, KEY_READ, &hkey))
{
- debug_printf ("User registry hive for %s already exists", name);
+ debug_printf ("User registry hive for %W already exists", name);
RegCloseKey (hkey);
return;
}
if (get_registry_hive_path (name, path))
{
- strcat (path, "\\NTUSER.DAT");
- if ((ret = RegLoadKeyA (HKEY_USERS, name, path)) != ERROR_SUCCESS)
- debug_printf ("Loading user registry hive for %s failed: %d", name, ret);
+ wcscat (path, L"\\NTUSER.DAT");
+ if ((ret = RegLoadKeyW (HKEY_USERS, name, path)) != ERROR_SUCCESS)
+ debug_printf ("Loading user registry hive for %W failed: %d", name, ret);
}
}
diff --git a/winsup/cygwin/registry.h b/winsup/cygwin/registry.h
index 3d1aea65d..472431188 100644
--- a/winsup/cygwin/registry.h
+++ b/winsup/cygwin/registry.h
@@ -40,5 +40,5 @@ public:
};
/* Evaluates path to the directory of the local user registry hive */
-char *__stdcall get_registry_hive_path (const char *name, char *path);
-void __stdcall load_registry_hive (const char *name);
+PWCHAR __stdcall get_registry_hive_path (const PWCHAR name, PWCHAR path);
+void __stdcall load_registry_hive (const PWCHAR name);
diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc
index 7fc9492ad..10aa6ca5a 100644
--- a/winsup/cygwin/sec_helper.cc
+++ b/winsup/cygwin/sec_helper.cc
@@ -101,6 +101,17 @@ cygpsid::get_id (BOOL search_grp, int *type)
return id;
}
+PWCHAR
+cygpsid::string (PWCHAR nsidstr) const
+{
+ UNICODE_STRING sid;
+
+ if (!psid || !nsidstr)
+ return NULL;
+ RtlInitEmptyUnicodeString (&sid, nsidstr, 256);
+ RtlConvertSidToUnicodeString (&sid, psid, FALSE);
+ return nsidstr;
+}
char *
cygpsid::string (char *nsidstr) const
diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h
index ba0a06a94..8d4db78e1 100644
--- a/winsup/cygwin/security.h
+++ b/winsup/cygwin/security.h
@@ -100,6 +100,7 @@ public:
int get_uid () { return get_id (FALSE); }
int get_gid () { return get_id (TRUE); }
+ PWCHAR string (PWCHAR nsidstr) const;
char *string (char *nsidstr) const;
bool operator== (const PSID nsid) const
diff --git a/winsup/cygwin/smallprint.cc b/winsup/cygwin/smallprint.cc
index f792dc084..a56a340bd 100644
--- a/winsup/cygwin/smallprint.cc
+++ b/winsup/cygwin/smallprint.cc
@@ -64,7 +64,7 @@ __rn (char *dst, int base, int dosign, long long val, int len, int pad, unsigned
extern "C" int
__small_vsprintf (char *dst, const char *fmt, va_list ap)
{
- char tmp[PATH_MAX];
+ char tmp[NT_MAX_PATH];
char *orig = dst;
const char *s;
PWCHAR w;
@@ -169,7 +169,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
dst = rnargLL (dst, 16, 0, len, pad);
break;
case 'P':
- if (!GetModuleFileName (NULL, tmp, PATH_MAX))
+ if (!GetModuleFileName (NULL, tmp, NT_MAX_PATH))
s = "cygwin program";
else
s = tmp;
diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc
index 92d7fc742..17343406c 100644
--- a/winsup/cygwin/strace.cc
+++ b/winsup/cygwin/strace.cc
@@ -154,7 +154,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap)
pn = NULL;
char *p;
- char progname[PATH_MAX];
+ char progname[NT_MAX_PATH];
if (!pn)
GetModuleFileName (NULL, pn = progname, sizeof (progname));
if (!pn)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 6e58b6aa7..ee038a067 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2483,7 +2483,7 @@ seteuid32 (__uid32_t uid)
if (new_token != hProcToken)
{
/* Avoid having HKCU use default user */
- char name[128];
+ WCHAR name[128];
load_registry_hive (usersid.string (name));
/* Try setting owner to same value as user. */
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index c91d77967..24903e4ae 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -408,12 +408,12 @@ cygheap_user::env_userprofile (const char *name, size_t namelen)
if (test_uid (puserprof, name, namelen))
return puserprof;
- char userprofile_env_buf[PATH_MAX];
- char win_id[UNLEN + 1]; /* Large enough for SID */
+ WCHAR userprofile_env_buf[NT_MAX_PATH];
+ WCHAR win_id[UNLEN + 1]; /* Large enough for SID */
cfree_and_set (puserprof, almost_null);
if (get_registry_hive_path (get_windows_id (win_id), userprofile_env_buf))
- puserprof = cstrdup (userprofile_env_buf);
+ sys_wcstombs_alloc (&puserprof, HEAP_STR, userprofile_env_buf);
return puserprof;
}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 952292862..dbb08e09e 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -61,7 +61,7 @@ extern unsigned long cygwin_inet_addr (const char *cp);
/* Note that MAX_PATH is defined in the windows headers */
/* There is also PATH_MAX and MAXPATHLEN.
- PATH_MAX is from Posix and does *not* include the trailing NUL.
+ PATH_MAX is from Posix and does include the trailing NUL.
MAXPATHLEN is from Unix.
Thou shalt use CYG_MAX_PATH throughout. It avoids the NUL vs no-NUL
@@ -76,6 +76,15 @@ extern unsigned long cygwin_inet_addr (const char *cp);
#define CYG_MAX_PATH (MAX_PATH)
+/* There's no define for the maximum path length the NT kernel can handle.
+ That's why we define our own to use in path length test and for path
+ buffer sizes. As MAX_PATH and PATH_MAX, this is defined including the
+ trailing 0. Internal buffers and internal path routines should use
+ NT_MAX_PATH. PATH_MAX as defined in limits.h is the maximum length of
+ application provided path strings we handle. */
+/* FIXME: The name is preliminary and TBD. */
+#define NT_MAX_PATH 32768
+
#ifdef __cplusplus
extern const char case_folded_lower[];