summaryrefslogtreecommitdiffstats
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-03-11 12:34:08 +0000
committerCorinna Vinschen <corinna@vinschen.de>2008-03-11 12:34:08 +0000
commit6c968f611bfa7045711f9844de2a5129257fbc1a (patch)
treeeaa7145edbd8a70303895b6a275898e9ad25d75d /winsup
parentbecf251f67689f14e1f9f3ba04b4b2ad586fc77e (diff)
downloadcygnal-6c968f611bfa7045711f9844de2a5129257fbc1a.tar.gz
cygnal-6c968f611bfa7045711f9844de2a5129257fbc1a.tar.bz2
cygnal-6c968f611bfa7045711f9844de2a5129257fbc1a.zip
* path.cc (cwdstuff::set): Make sure drive_length is 0 for virtual
paths. Add comments. * spawn.cc (spawn_guts): Don't allow to start a native Win32 application from a long path or a virtual path. Print an error message to stderr.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/path.cc8
-rw-r--r--winsup/cygwin/spawn.cc15
3 files changed, 27 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 3ed49c983..c4bf85a3e 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,12 @@
2008-03-11 Corinna Vinschen <corinna@vinschen.de>
+ * path.cc (cwdstuff::set): Make sure drive_length is 0 for virtual
+ paths. Add comments.
+ * spawn.cc (spawn_guts): Don't allow to start a native Win32 application
+ from a long path or a virtual path. Print an error message to stderr.
+
+2008-03-11 Corinna Vinschen <corinna@vinschen.de>
+
* environ.cc (parse_options): Use tmp_pathbuf to allocate buffer.
(regopt): Take tmp buffer as additional argument.
(environ_init): Alllcate tmpbuf earlier. Use as temporary buffer in
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 253f97e0f..1ddf9cda0 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -4630,9 +4630,11 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit)
}
/* Make sure it's NUL-termniated. */
win32.Buffer[win32.Length / sizeof (WCHAR)] = L'\0';
- if (win32.Buffer[1] == L':')
+ if (!doit) /* Virtual path */
+ drive_length = 0;
+ else if (win32.Buffer[1] == L':') /* X: */
drive_length = 2;
- else if (win32.Buffer[1] == L'\\')
+ else if (win32.Buffer[1] == L'\\') /* UNC path */
{
PWCHAR ptr = wcschr (win32.Buffer + 2, L'\\');
if (ptr)
@@ -4642,7 +4644,7 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit)
else
drive_length = win32.Length / sizeof (WCHAR);
}
- else
+ else /* Shouldn't happen */
drive_length = 0;
tmp_pathbuf tp;
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 4ea04d934..9d6b25261 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -361,6 +361,21 @@ spawn_guts (const char * prog_arg, const char *const *argv,
wascygexec = real_path.iscygexec ();
res = newargv.fixup (prog_arg, real_path, ext);
+
+ if (!real_path.iscygexec ()
+ && (cygheap->cwd.drive_length == 0
+ || cygheap->cwd.win32.Length >= MAX_PATH * sizeof (WCHAR)))
+ {
+ small_printf ("Error: Current working directory is a %s.\n"
+ "Can't start native Windows application from here.\n\n",
+ cygheap->cwd.drive_length == 0
+ ? "virtual Cygwin directory"
+ : "path longer than allowed for a\n"
+ "Win32 working directory");
+ set_errno (ENAMETOOLONG);
+ res = -1;
+ goto out;
+ }
if (res)
goto out;