diff --git a/contrib/win32/win32compat/misc.c b/contrib/win32/win32compat/misc.c index c75625e2f..5f390d4c8 100644 --- a/contrib/win32/win32compat/misc.c +++ b/contrib/win32/win32compat/misc.c @@ -672,38 +672,23 @@ convertToForwardslash(char *str) { } /* -* This method will expands all symbolic links and resolves references to /./, -* /../ and extra '/' characters in the null-terminated string named by +* This method will resolves references to /./, /../ and extra '/' characters in the null-terminated string named by * path to produce a canonicalized absolute pathname. */ char * realpath(const char *path, char resolved[MAX_PATH]) { char tempPath[MAX_PATH]; - - if ((0 == strcmp(path, "./")) || (0 == strcmp(path, "."))) { - tempPath[0] = '/'; - _getcwd(&tempPath[1], sizeof(tempPath) - 1); - convertToForwardslash(tempPath); - - strncpy(resolved, tempPath, strlen(tempPath) + 1); - return resolved; - } - - if (path[0] != '/') - strlcpy(resolved, path, sizeof(tempPath)); + + if (*path == '/' && *(path + 2) == ':') + strncpy(resolved, path + 1, strlen(path)); // skip the first '/' else - strlcpy(resolved, path + 1, sizeof(tempPath)); + strncpy(resolved, path, strlen(path) + 1); - convertToBackslash(resolved); - PathCanonicalizeA(tempPath, resolved); + if (_fullpath(tempPath, resolved, MAX_PATH) == NULL) + return NULL; + convertToForwardslash(tempPath); - // Store terminating slash in 'X:/' on Windows. - if (tempPath[1] == ':' && tempPath[2] == 0) { - tempPath[2] = '/'; - tempPath[3] = 0; - } - resolved[0] = '/'; // will be our first slash in /x:/users/test1 format strncpy(resolved + 1, tempPath, sizeof(tempPath) - 1); return resolved; diff --git a/sftp.c b/sftp.c index 341410c18..fe8de3722 100644 --- a/sftp.c +++ b/sftp.c @@ -2333,6 +2333,7 @@ connect_to_server(char *path, char **args, int *in, int *out) fcntl(pout[1], F_SETFD, FD_CLOEXEC); fcntl(pin[0], F_SETFD, FD_CLOEXEC); + memcpy(full_cmd, "sftp-server.exe", 16); sshpid = spawn_child(full_cmd, c_in, c_out, STDERR_FILENO, 0); free(full_cmd); }