Skip to content

Commit

Permalink
check on absolute path from Linux to Windows machine
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobBarthelmeh committed Jul 13, 2023
1 parent d6f0294 commit 5d8a64f
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 5d8a64f

Please sign in to comment.