This imports https://github.com/msys2/msys2-runtime/pull/110 into the `MSYS2-packages` repository, fixing a regression where `cmd /c <command>` caused a `Bad address` error. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
56 lines
1.8 KiB
Diff
56 lines
1.8 KiB
Diff
From 4676ec44f24a0bfa208e6f0c79b0b059c88f6b1a Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B8=CC=86=20=D0=9F?=
|
|
=?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=BE=D0=B2?= <alexey.pawlow@gmail.com>
|
|
Date: Sun, 14 Apr 2019 22:13:51 +0300
|
|
Subject: [PATCH 10/N] Special case for converting root directory to have
|
|
training slash
|
|
|
|
---
|
|
winsup/cygwin/path.cc | 25 ++++++++++++++++---------
|
|
1 file changed, 16 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
|
|
index 17646a8..77480aa 100644
|
|
--- a/winsup/cygwin/path.cc
|
|
+++ b/winsup/cygwin/path.cc
|
|
@@ -709,6 +709,12 @@ path_conv::check (const char *src, unsigned opt,
|
|
need_directory = 1;
|
|
*--tail = '\0';
|
|
}
|
|
+ /* Special case for "/" must set need_directory, without removing
|
|
+ trailing slash */
|
|
+ else if (tail == path_copy + 1 && isslash (tail[-1]))
|
|
+ {
|
|
+ need_directory = 1;
|
|
+ }
|
|
path_end = tail;
|
|
|
|
/* Scan path_copy from right to left looking either for a symlink
|
|
@@ -1248,16 +1254,17 @@ path_conv::check (const char *src, unsigned opt,
|
|
cfree (wide_path);
|
|
wide_path = NULL;
|
|
}
|
|
- if (need_directory)
|
|
+ }
|
|
+
|
|
+ if (need_directory)
|
|
+ {
|
|
+ size_t n = strlen (this->path);
|
|
+ /* Do not add trailing \ to UNC device names like \\.\a: */
|
|
+ if (this->path[n - 1] != '\\' &&
|
|
+ (strncmp (this->path, "\\\\.\\", 4) != 0))
|
|
{
|
|
- size_t n = strlen (this->path);
|
|
- /* Do not add trailing \ to UNC device names like \\.\a: */
|
|
- if (this->path[n - 1] != '\\' &&
|
|
- (strncmp (this->path, "\\\\.\\", 4) != 0))
|
|
- {
|
|
- this->modifiable_path ()[n] = '\\';
|
|
- this->modifiable_path ()[n + 1] = '\0';
|
|
- }
|
|
+ this->modifiable_path ()[n] = '\\';
|
|
+ this->modifiable_path ()[n + 1] = '\0';
|
|
}
|
|
}
|
|
|