verify_path: consider dos drive prefix
If someone manage to create a repo with a 'C:' entry in the root-tree, files can be written outside of the working-dir. This opens up a can-of-worms of exploits. Fix it by explicitly checking for a dos drive prefix when verifying a paht. While we're at it, make sure that paths beginning with '\' is considered absolute as well. Noticed-by: Theo Niessink <theo@taletn.com> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Erik Faye-Lund committed
May 27, 2011 at 18:00 UTC
56948cb6aa8189e3b77c700119d179172e0f8c4a
1 file changed
+4
-1
read-cache.c
+4
-1
@@ -774,11 +774,14 @@ int verify_path(const char *path)
774
{
775
char c;
776
777
+ if (has_dos_drive_prefix(path))
778
+ return 0;
779
+
780
goto inside;
781
for (;;) {
782
if (!c)
783
return 1;
781
- if (c == '/') {
784
+ if (is_dir_sep(c)) {
785
inside:
786
c = *path++;
787
switch (c) {