mingw: handle `subst`-ed "DOS drives"

Over a decade ago, in 25fe217b86c (Windows: Treat Windows style path
names., 2008-03-05), Git was taught to handle absolute Windows paths,
i.e. paths that start with a drive letter and a colon.

Unbeknownst to us, while drive letters of physical drives are limited to
letters of the English alphabet, there is a way to assign virtual drive
letters to arbitrary directories, via the `subst` command, which is
_not_ limited to English letters.

It is therefore possible to have absolute Windows paths of the form
`1:\what\the\hex.txt`. Even "better": pretty much arbitrary Unicode
letters can also be used, e.g. `ä:\tschibät.sch`.

While it can be sensibly argued that users who set up such funny drive
letters really seek adverse consequences, the Windows Operating System
is known to be a platform where many users are at the mercy of
administrators who have their very own idea of what constitutes a
reasonable setup.

Therefore, let's just make sure that such funny paths are still
considered absolute paths by Git, on Windows.

In addition to Unicode characters, pretty much any character is a valid
drive letter, as far as `subst` is concerned, even `:` and `"` or even a
space character. While it is probably the opposite of smart to use them,
let's safeguard `is_dos_drive_prefix()` against all of them.

Note: `[::1]:repo` is a valid URL, but not a valid path on Windows.
As `[` is now considered a valid drive letter, we need to be very
careful to avoid misinterpreting such a string as valid local path in
`url_is_local_not_ssh()`. To do that, we use the just-introduced
function `is_valid_path()` (which will label the string as invalid file
name because of the colon characters).

This fixes CVE-2019-1351.

Reported-by: Nicolas Joly <Nicolas.Joly@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 files changed
tree: 1625e0241be5d0ffefe15b39133c8bc5068a021d
  1. .gitattributes
  2. .github/
  3. .gitignore
  4. .gitmodules
  5. .mailmap
  6. .travis.yml
  7. .tsan-suppressions
  8. COPYING
  9. Documentation/
  10. GIT-VERSION-GEN
  11. INSTALL
  12. LGPL-2.1
  13. Makefile
  14. README.md
  15. abspath.c
  16. aclocal.m4
  17. advice.c
  18. advice.h
  19. alias.c
  20. alloc.c
  21. apply.c
  22. apply.h
  23. archive-tar.c
  24. archive-zip.c
  25. archive.c
  26. archive.h
  27. argv-array.c
  28. argv-array.h
  29. attr.c
  30. attr.h
  31. base85.c
  32. bisect.c
  33. bisect.h
  34. blame.c
  35. blame.h
  36. blob.c
  37. blob.h
  38. block-sha1/
  39. branch.c
  40. branch.h
  41. builtin.h
  42. builtin/
  43. bulk-checkin.c
  44. bulk-checkin.h
  45. bundle.c
  46. bundle.h
  47. cache-tree.c
  48. cache-tree.h
  49. cache.h
  50. check-builtins.sh
  51. check-racy.c
  52. check_bindir
  53. ci/
  54. color.c
  55. color.h
  56. column.c
  57. column.h
  58. combine-diff.c
  59. command-list.txt
  60. commit-slab.h
  61. commit.c
  62. commit.h
  63. common-main.c
  64. compat/
  65. config.c
  66. config.h
  67. config.mak.in
  68. config.mak.uname
  69. configure.ac
  70. connect.c
  71. connect.h
  72. connected.c
  73. connected.h
  74. contrib/
  75. convert.c
  76. convert.h
  77. copy.c
  78. credential-cache--daemon.c
  79. credential-cache.c
  80. credential-store.c
  81. credential.c
  82. credential.h
  83. csum-file.c
  84. csum-file.h
  85. ctype.c
  86. daemon.c
  87. date.c
  88. decorate.c
  89. decorate.h
  90. delta.h
  91. diff-delta.c
  92. diff-lib.c
  93. diff-no-index.c
  94. diff.c
  95. diff.h
  96. diffcore-break.c
  97. diffcore-delta.c
  98. diffcore-order.c
  99. diffcore-pickaxe.c
  100. diffcore-rename.c
  101. diffcore.h
  102. dir-iterator.c
  103. dir-iterator.h
  104. dir.c
  105. dir.h
  106. editor.c
  107. entry.c
  108. environment.c
  109. ewah/
  110. exec_cmd.c
  111. exec_cmd.h
  112. fast-import.c
  113. fetch-pack.c
  114. fetch-pack.h
  115. fmt-merge-msg.h
  116. fsck.c
  117. fsck.h
  118. generate-cmdlist.sh
  119. gettext.c
  120. gettext.h
  121. git-add--interactive.perl
  122. git-archimport.perl
  123. git-bisect.sh
  124. git-compat-util.h
  125. git-cvsexportcommit.perl
  126. git-cvsimport.perl
  127. git-cvsserver.perl
  128. git-difftool--helper.sh
  129. git-filter-branch.sh
  130. git-gui/
  131. git-instaweb.sh
  132. git-merge-octopus.sh
  133. git-merge-one-file.sh
  134. git-merge-resolve.sh
  135. git-mergetool--lib.sh
  136. git-mergetool.sh
  137. git-p4.py
  138. git-parse-remote.sh
  139. git-quiltimport.sh
  140. git-rebase--am.sh
  141. git-rebase--interactive.sh
  142. git-rebase--merge.sh
  143. git-rebase.sh
  144. git-remote-testgit.sh
  145. git-request-pull.sh
  146. git-send-email.perl
  147. git-sh-i18n.sh
  148. git-sh-setup.sh
  149. git-stash.sh
  150. git-submodule.sh
  151. git-svn.perl
  152. git-web--browse.sh
  153. git.c
  154. git.rc
  155. gitk-git/
  156. gitweb/
  157. gpg-interface.c
  158. gpg-interface.h
  159. graph.c
  160. graph.h
  161. grep.c
  162. grep.h
  163. hash.h
  164. hashmap.c
  165. hashmap.h
  166. help.c
  167. help.h
  168. hex.c
  169. http-backend.c
  170. http-fetch.c
  171. http-push.c
  172. http-walker.c
  173. http.c
  174. http.h
  175. ident.c
  176. imap-send.c
  177. iterator.h
  178. khash.h
  179. kwset.c
  180. kwset.h
  181. levenshtein.c
  182. levenshtein.h
  183. line-log.c
  184. line-log.h
  185. line-range.c
  186. line-range.h
  187. list-objects.c
  188. list-objects.h
  189. list.h
  190. ll-merge.c
  191. ll-merge.h
  192. lockfile.c
  193. lockfile.h
  194. log-tree.c
  195. log-tree.h
  196. mailinfo.c
  197. mailinfo.h
  198. mailmap.c
  199. mailmap.h
  200. match-trees.c
  201. merge-blobs.c
  202. merge-blobs.h
  203. merge-recursive.c
  204. merge-recursive.h
  205. merge.c
  206. mergesort.c
  207. mergesort.h
  208. mergetools/
  209. mru.c
  210. mru.h
  211. name-hash.c
  212. notes-cache.c
  213. notes-cache.h
  214. notes-merge.c
  215. notes-merge.h
  216. notes-utils.c
  217. notes-utils.h
  218. notes.c
  219. notes.h
  220. object.c
  221. object.h
  222. oidset.c
  223. oidset.h
  224. pack-bitmap-write.c
  225. pack-bitmap.c
  226. pack-bitmap.h
  227. pack-check.c
  228. pack-objects.c
  229. pack-objects.h
  230. pack-revindex.c
  231. pack-revindex.h
  232. pack-write.c
  233. pack.h
  234. pager.c
  235. parse-options-cb.c
  236. parse-options.c
  237. parse-options.h
  238. patch-delta.c
  239. patch-ids.c
  240. patch-ids.h
  241. path.c
  242. path.h
  243. pathspec.c
  244. pathspec.h
  245. perl/
  246. pkt-line.c
  247. pkt-line.h
  248. po/
  249. ppc/
  250. preload-index.c
  251. pretty.c
  252. prio-queue.c
  253. prio-queue.h
  254. progress.c
  255. progress.h
  256. prompt.c
  257. prompt.h
  258. quote.c
  259. quote.h
  260. reachable.c
  261. reachable.h
  262. read-cache.c
  263. ref-filter.c
  264. ref-filter.h
  265. reflog-walk.c
  266. reflog-walk.h
  267. refs.c
  268. refs.h
  269. refs/
  270. remote-curl.c
  271. remote-testsvn.c
  272. remote.c
  273. remote.h
  274. replace_object.c
  275. repository.c
  276. repository.h
  277. rerere.c
  278. rerere.h
  279. resolve-undo.c
  280. resolve-undo.h
  281. revision.c
  282. revision.h
  283. run-command.c
  284. run-command.h
  285. send-pack.c
  286. send-pack.h
  287. sequencer.c
  288. sequencer.h
  289. server-info.c
  290. setup.c
  291. sh-i18n--envsubst.c
  292. sha1-array.c
  293. sha1-array.h
  294. sha1-lookup.c
  295. sha1-lookup.h
  296. sha1_file.c
  297. sha1_name.c
  298. sha1dc/
  299. sha1dc_git.c
  300. sha1dc_git.h
  301. shallow.c
  302. shell.c
  303. shortlog.h
  304. show-index.c
  305. sideband.c
  306. sideband.h
  307. sigchain.c
  308. sigchain.h
  309. split-index.c
  310. split-index.h
  311. strbuf.c
  312. strbuf.h
  313. streaming.c
  314. streaming.h
  315. string-list.c
  316. string-list.h
  317. sub-process.c
  318. sub-process.h
  319. submodule-config.c
  320. submodule-config.h
  321. submodule.c
  322. submodule.h
  323. symlinks.c
  324. t/
  325. tag.c
  326. tag.h
  327. tar.h
  328. tempfile.c
  329. tempfile.h
  330. templates/
  331. thread-utils.c
  332. thread-utils.h
  333. tmp-objdir.c
  334. tmp-objdir.h
  335. trace.c
  336. trace.h
  337. trailer.c
  338. trailer.h
  339. transport-helper.c
  340. transport.c
  341. transport.h
  342. tree-diff.c
  343. tree-walk.c
  344. tree-walk.h
  345. tree.c
  346. tree.h
  347. unicode_width.h
  348. unimplemented.sh
  349. unix-socket.c
  350. unix-socket.h
  351. unpack-trees.c
  352. unpack-trees.h
  353. upload-pack.c
  354. url.c
  355. url.h
  356. urlmatch.c
  357. urlmatch.h
  358. usage.c
  359. userdiff.c
  360. userdiff.h
  361. utf8.c
  362. utf8.h
  363. varint.c
  364. varint.h
  365. vcs-svn/
  366. version.c
  367. version.h
  368. versioncmp.c
  369. walker.c
  370. walker.h
  371. wildmatch.c
  372. wildmatch.h
  373. worktree.c
  374. worktree.h
  375. wrap-for-bin.sh
  376. wrapper.c
  377. write_or_die.c
  378. ws.c
  379. wt-status.c
  380. wt-status.h
  381. xdiff-interface.c
  382. xdiff-interface.h
  383. xdiff/
  384. zlib.c
README.md

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://public-inbox.org/git/, http://marc.info/?l=git and other archival sites.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks