]> sourceware.org Git - newlib-cygwin.git/commitdiff
* cygheap.cc (cwcsdup): New function.
authorCorinna Vinschen <corinna@vinschen.de>
Thu, 14 Feb 2008 16:47:11 +0000 (16:47 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Thu, 14 Feb 2008 16:47:11 +0000 (16:47 +0000)
(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.

23 files changed:
winsup/cygwin/ChangeLog
winsup/cygwin/cygheap.cc
winsup/cygwin/cygheap.h
winsup/cygwin/dcrt0.cc
winsup/cygwin/dll_init.cc
winsup/cygwin/dll_init.h
winsup/cygwin/environ.cc
winsup/cygwin/exceptions.cc
winsup/cygwin/fhandler_process.cc
winsup/cygwin/include/limits.h
winsup/cygwin/include/sys/cygwin.h
winsup/cygwin/path.cc
winsup/cygwin/pinfo.cc
winsup/cygwin/pinfo.h
winsup/cygwin/registry.cc
winsup/cygwin/registry.h
winsup/cygwin/sec_helper.cc
winsup/cygwin/security.h
winsup/cygwin/smallprint.cc
winsup/cygwin/strace.cc
winsup/cygwin/syscalls.cc
winsup/cygwin/uinfo.cc
winsup/cygwin/winsup.h

index 117cc10fdd4b93de9c87942a328c7fa4eb674bd2..bc0630ba40ac60bc34c92b19cf8d33004ce4632c 100644 (file)
@@ -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.
index 23e193bc3c1d9632233a3c0a7b477e590313a23f..e3a2918b78608cf6fb437003fb2b4ee9f7bba906 100644 (file)
@@ -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)
 {
index 7d232584a9e8c1402dbf4efe1e0a185fad1d19e9..567aecf697d10686e6cc0a9e116607f701df540b 100644 (file)
@@ -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)));
index 0398388df68d5d5c7a8e6d05fb6636949e3ff40e..4ca329405294c3cb4517313edbdbba2186aac99b 100644 (file)
@@ -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);
        }
index d7677121607b4216ab5756bc2c0ed0e942dad238..3e143abc1e67010219e80a46479f449b95e50921 100644 (file)
@@ -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? */
index cd88c564a2c2bc8923cb53f70afe79dc2999ced2..205123a2f52411a7d7b96f653071c8f9f9788471 100644 (file)
@@ -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 ();
 };
index 3e0765bcffef0feb012973453b597e30a13f71b3..a7c6931689723f94dabaab270285db6ae7b2c13a 100644 (file)
@@ -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)
index 05cc91696dea77bb11091d3bf96d2969b252323e..73f6790dc43be515115e43f07cba0768659184a8 100644 (file)
@@ -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 = '/';
index 380c25862d64972b9e19d60ba6d9a97136d994ab..595488c9996fbb8185dce14175ed5bdee12664d0 100644 (file)
@@ -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;
index e6e089da9eaa33b7df7ef6bf4c568bb70f3b9d00..20dd84a0b051c64cafd3fbacb8a6199e425f8f2b 100644 (file)
@@ -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. */
index b8738fa7021c24881fa39f6f6f73d758bdc910f8..287cc1db364ff268a3c8cdd6426e812d0c9c07c1 100644 (file)
@@ -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*/
index e013d0b74b64cf00657f34cda42b764d6542f7be..56ec17406188e352fa536ee3b73584471e7ae0a0 100644 (file)
@@ -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;
index d1565f80dbfa5818ec7c4cf4da995f17a854392e..632cc5f71142887536772bb746b0c1f37f92842a 100644 (file)
@@ -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;
index 3c5e100fbee2470734360ab0eb5b7975e5778cc9..18346fe83fa4ab9a9ffc2a784d14444897825782 100644 (file)
@@ -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,
index 3c67ff62fbc531ab55aaeeefc1af6bda4ed8a65a..93eb113866dce856a1ff536c9990df82d8a7d11a 100644 (file)
@@ -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);
     }
 }
 
index 3d1aea65d24abb5dfdd29405b33ba475dcf3435a..472431188ae69743486b9205c364b30c70504cbf 100644 (file)
@@ -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);
index 7fc9492ad6406370c8d534436b17513110ac15ce..10aa6ca5ac676bfa7e3487bd8624aef0e427506b 100644 (file)
@@ -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
index ba0a06a9488f3d8edd2961cfe1f532ab02265838..8d4db78e143df106dd96531358e10f7ef0a25118 100644 (file)
@@ -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
index f792dc0849d26fbe89d3bf92f8cbbcf4bfad9ef8..a56a340bd0471ee8a636aaaab2862a1160687a79 100644 (file)
@@ -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;
index 92d7fc742173c74dc0b9a2f3c5bbed35ef1e4abd..17343406cc6eaaeaa96511640b5584c08d0444e8 100644 (file)
@@ -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)
index 6e58b6aa7c5e5370d8c269496f36c1b053cc4c89..ee038a06789c8d28c29bca9d7881e47655b9cf30 100644 (file)
@@ -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. */
index c91d77967055dbf977a7e1a1435ae41e9091f4b3..24903e4ae0d28b5d36d5a918196e214c18d7d676 100644 (file)
@@ -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;
 }
index 9522928628b1ca28d73af614637d0b97bc9fb237..dbb08e09ebca50a3a828823fafc73c5f0db65a20 100644 (file)
@@ -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[];
This page took 0.057451 seconds and 5 git commands to generate.