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 authored and falemagn committed Jul 21, 2023
1 parent 6bd018c commit a43fb85
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 a43fb85

Please sign in to comment.