mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-28 00:04:30 +02:00
realpath fix
This commit is contained in:
parent
07a658c2b7
commit
79e00ae7de
@ -672,38 +672,23 @@ convertToForwardslash(char *str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This method will expands all symbolic links and resolves references to /./,
|
* This method will resolves references to /./, /../ and extra '/' characters in the null-terminated string named by
|
||||||
* /../ and extra '/' characters in the null-terminated string named by
|
|
||||||
* path to produce a canonicalized absolute pathname.
|
* path to produce a canonicalized absolute pathname.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
realpath(const char *path, char resolved[MAX_PATH]) {
|
realpath(const char *path, char resolved[MAX_PATH]) {
|
||||||
char tempPath[MAX_PATH];
|
char tempPath[MAX_PATH];
|
||||||
|
|
||||||
if ((0 == strcmp(path, "./")) || (0 == strcmp(path, "."))) {
|
if (*path == '/' && *(path + 2) == ':')
|
||||||
tempPath[0] = '/';
|
strncpy(resolved, path + 1, strlen(path)); // skip the first '/'
|
||||||
_getcwd(&tempPath[1], sizeof(tempPath) - 1);
|
|
||||||
convertToForwardslash(tempPath);
|
|
||||||
|
|
||||||
strncpy(resolved, tempPath, strlen(tempPath) + 1);
|
|
||||||
return resolved;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path[0] != '/')
|
|
||||||
strlcpy(resolved, path, sizeof(tempPath));
|
|
||||||
else
|
else
|
||||||
strlcpy(resolved, path + 1, sizeof(tempPath));
|
strncpy(resolved, path, strlen(path) + 1);
|
||||||
|
|
||||||
|
if (_fullpath(tempPath, resolved, MAX_PATH) == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
convertToBackslash(resolved);
|
|
||||||
PathCanonicalizeA(tempPath, resolved);
|
|
||||||
convertToForwardslash(tempPath);
|
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
|
resolved[0] = '/'; // will be our first slash in /x:/users/test1 format
|
||||||
strncpy(resolved + 1, tempPath, sizeof(tempPath) - 1);
|
strncpy(resolved + 1, tempPath, sizeof(tempPath) - 1);
|
||||||
return resolved;
|
return resolved;
|
||||||
|
1
sftp.c
1
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(pout[1], F_SETFD, FD_CLOEXEC);
|
||||||
fcntl(pin[0], 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);
|
sshpid = spawn_child(full_cmd, c_in, c_out, STDERR_FILENO, 0);
|
||||||
free(full_cmd);
|
free(full_cmd);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user