diff options
author | Axel Rasmussen <axelrasmussen@google.com> | 2015-10-01 18:01:32 -0700 |
---|---|---|
committer | Axel Rasmussen <axelrasmussen@google.com> | 2015-10-01 18:01:32 -0700 |
commit | c7b17fb5cd1adac57c4300e95cef8c7064b0601a (patch) | |
tree | b1a1bcd6e1d88f1cd48b7fdb414d6444c28eb896 /src/win32 | |
parent | 28cdb3153c8c6d651c5b2afcf315a2d188e9fde9 (diff) | |
parent | a99f33e9b05504ea5eccd9c9210cd4a9e8d11695 (diff) | |
download | libgit2-c7b17fb5cd1adac57c4300e95cef8c7064b0601a.tar.gz |
Merge branch 'master' into nsec_fix_next
Diffstat (limited to 'src/win32')
-rw-r--r-- | src/win32/path_w32.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/win32/path_w32.c b/src/win32/path_w32.c index 118e8bcc5..40b95c33b 100644 --- a/src/win32/path_w32.c +++ b/src/win32/path_w32.c @@ -198,13 +198,13 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src) /* See if this is an absolute path (beginning with a drive letter) */ if (path__is_absolute(src)) { if (git__utf8_to_16(dest, MAX_PATH, src) < 0) - return -1; + goto on_error; } /* File-prefixed NT-style paths beginning with \\?\ */ else if (path__is_nt_namespace(src)) { /* Skip the NT prefix, the destination already contains it */ if (git__utf8_to_16(dest, MAX_PATH, src + PATH__NT_NAMESPACE_LEN) < 0) - return -1; + goto on_error; } /* UNC paths */ else if (path__is_unc(src)) { @@ -213,36 +213,43 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src) /* Skip the leading "\\" */ if (git__utf8_to_16(dest, MAX_PATH - 2, src + 2) < 0) - return -1; + goto on_error; } /* Absolute paths omitting the drive letter */ else if (src[0] == '\\' || src[0] == '/') { if (path__cwd(dest, MAX_PATH) < 0) - return -1; + goto on_error; if (!path__is_absolute(dest)) { errno = ENOENT; - return -1; + goto on_error; } /* Skip the drive letter specification ("C:") */ if (git__utf8_to_16(dest + 2, MAX_PATH - 2, src) < 0) - return -1; + goto on_error; } /* Relative paths */ else { int cwd_len; if ((cwd_len = git_win32_path__cwd(dest, MAX_PATH)) < 0) - return -1; + goto on_error; dest[cwd_len++] = L'\\'; if (git__utf8_to_16(dest + cwd_len, MAX_PATH - cwd_len, src) < 0) - return -1; + goto on_error; } return git_win32_path_canonicalize(out); + +on_error: + /* set windows error code so we can use its error message */ + if (errno == ENAMETOOLONG) + SetLastError(ERROR_FILENAME_EXCED_RANGE); + + return -1; } int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src) |