summaryrefslogtreecommitdiff
path: root/compat/mingw.h
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2019-09-16 11:26:40 (GMT)
committerJohannes Schindelin <johannes.schindelin@gmx.de>2019-12-05 14:37:09 (GMT)
commit65d30a19de282d781c59bb7f807459cb5b29de1e (patch)
treece238c2e1919a98b6079d1d81c69d3e464d754c9 /compat/mingw.h
parent5532ebdeb7ac56d952addb94ea9741d3c8f5b6f6 (diff)
parentd2c84dad1c88f40906799bc879f70b965efd8ba6 (diff)
downloadgit-65d30a19de282d781c59bb7f807459cb5b29de1e.zip
git-65d30a19de282d781c59bb7f807459cb5b29de1e.tar.gz
git-65d30a19de282d781c59bb7f807459cb5b29de1e.tar.bz2
Merge branch 'win32-filenames-cannot-have-trailing-spaces-or-periods'
On Windows, filenames cannot have trailing spaces or periods, when opening such paths, they are stripped automatically. Read: you can open the file `README` via the file name `README . . .`. This ambiguity can be used in combination with other security bugs to cause e.g. remote code execution during recursive clones. This patch series fixes that. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diffstat (limited to 'compat/mingw.h')
-rw-r--r--compat/mingw.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/compat/mingw.h b/compat/mingw.h
index e03aecf..8c49c1d 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -429,6 +429,17 @@ int mingw_offset_1st_component(const char *path);
#endif
/**
+ * Verifies that the given path is a valid one on Windows.
+ *
+ * In particular, path segments are disallowed which end in a period or a
+ * space (except the special directories `.` and `..`).
+ *
+ * Returns 1 upon success, otherwise 0.
+ */
+int is_valid_win32_path(const char *path);
+#define is_valid_path(path) is_valid_win32_path(path)
+
+/**
* Converts UTF-8 encoded string to UTF-16LE.
*
* To support repositories with legacy-encoded file names, invalid UTF-8 bytes