diff options
| author | nulltoken <emeric.fermas@gmail.com> | 2011-03-18 19:10:36 +0100 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-03-23 00:17:25 +0200 |
| commit | 3644e98fd984c039d0c84b2311b410583739b6a5 (patch) | |
| tree | dbce981bcbc23b3f212746717f93979b8321918f /src/fileops.c | |
| parent | c90292ce4f852ff9f0e8ec4ddc7cdc438745790d (diff) | |
| download | libgit2-3644e98fd984c039d0c84b2311b410583739b6a5.tar.gz | |
Fix detection of attempt to escape the root directory on Windows
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/fileops.c b/src/fileops.c index 41239091b..e440ea6ab 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -503,13 +503,15 @@ int gitfo_mkdir_recurs(const char *path, int mode) static int retrieve_previous_path_component_start(const char *path) { - int offset, len, start = 0; - + int offset, len, root_offset, start = 0; + + root_offset = retrieve_path_root_offset(path); + if (root_offset > -1) + start += root_offset; + len = strlen(path); offset = len - 1; - //TODO: Deal with Windows rooted path - /* Skip leading slash */ if (path[start] == '/') start++; @@ -518,7 +520,7 @@ static int retrieve_previous_path_component_start(const char *path) if (path[offset] == '/') offset--; - if (offset < 0) + if (offset < root_offset) return GIT_ERROR; while (offset > start && path[offset-1] != '/') { |
