Skip to content

Commit

Permalink
Merge pull request #538 from JacobBarthelmeh/sftp
Browse files Browse the repository at this point in the history
check on absolute path from Linux to Windows machine
  • Loading branch information
SparkiDev authored Jul 14, 2023
2 parents d6f0294 + 5d8a64f commit 87caf4a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions examples/sftpclient/sftpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,22 @@ static int doAutopilot(int cmd, char* local, char* remote)
int ret = WS_SUCCESS;
char fullpath[128] = ".";
WS_SFTPNAME* name = NULL;
byte remoteAbsPath = 0;

if (remote != NULL && remote[0] == '/') {
/* use remote absolute path if provided */
/* check if is absolute path before making it one */
if (remote != NULL && WSTRLEN(remote) > 2 && remote[1] == ':' &&
remote[2] == '\\') {
remoteAbsPath = 1;
}
else if (remote != NULL && WSTRLEN(remote) > 2 && remote[1] == ':' &&
remote[2] == '/') {
remoteAbsPath = 1;
}
else if (remote != NULL && remote[0] == '/') {
remoteAbsPath = 1;
}

if (remoteAbsPath) {
WMEMSET(fullpath, 0, sizeof(fullpath));
WSTRNCPY(fullpath, remote, sizeof(fullpath) - 1);
}
Expand Down

0 comments on commit 87caf4a

Please sign in to comment.