mirror of https://github.com/wolfSSL/wolfssh.git
Merge pull request #490 from JacobBarthelmeh/sftp-path
handle full path used with SFTP Get-Put commandspull/492/head
commit
7c92e34180
|
@ -1523,8 +1523,14 @@ static int doAutopilot(int cmd, char* local, char* remote)
|
||||||
int err;
|
int err;
|
||||||
int ret = WS_SUCCESS;
|
int ret = WS_SUCCESS;
|
||||||
char fullpath[128] = ".";
|
char fullpath[128] = ".";
|
||||||
WS_SFTPNAME* name;
|
WS_SFTPNAME* name = NULL;
|
||||||
|
|
||||||
|
if (remote != NULL && remote[0] == '/') {
|
||||||
|
/* use remote absolute path if provided */
|
||||||
|
WMEMSET(fullpath, 0, sizeof(fullpath));
|
||||||
|
WSTRNCPY(fullpath, remote, sizeof(fullpath) - 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
do {
|
do {
|
||||||
name = wolfSSH_SFTP_RealPath(ssh, fullpath);
|
name = wolfSSH_SFTP_RealPath(ssh, fullpath);
|
||||||
err = wolfSSH_get_error(ssh);
|
err = wolfSSH_get_error(ssh);
|
||||||
|
@ -1534,6 +1540,7 @@ static int doAutopilot(int cmd, char* local, char* remote)
|
||||||
snprintf(fullpath, sizeof(fullpath), "%s/%s",
|
snprintf(fullpath, sizeof(fullpath), "%s/%s",
|
||||||
name == NULL ? "." : name->fName,
|
name == NULL ? "." : name->fName,
|
||||||
remote);
|
remote);
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (cmd == AUTOPILOT_PUT) {
|
if (cmd == AUTOPILOT_PUT) {
|
||||||
|
|
|
@ -119,4 +119,22 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# using full path test.
|
||||||
|
rm -rf sample2-copy.txt
|
||||||
|
PWD=`pwd`
|
||||||
|
if ! ./examples/sftpclient/wolfsftp -u jill -P upthehill -p "$PORT" \
|
||||||
|
-g -l sample2.txt -r $PWD/sample2-copy.txt
|
||||||
|
then
|
||||||
|
echo "Unable to put file using full path."
|
||||||
|
do_cleanup
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! diff sample2.txt sample2-copy.txt >/dev/null
|
||||||
|
then
|
||||||
|
echo "Put test files do not match after using full path."
|
||||||
|
do_cleanup
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
do_cleanup
|
do_cleanup
|
||||||
|
|
Loading…
Reference in New Issue