diff --git a/scripts/get-put.test b/scripts/get-put.test index 9be26740..b9f2a8eb 100755 --- a/scripts/get-put.test +++ b/scripts/get-put.test @@ -86,6 +86,16 @@ then exit 1 fi +# Test fail on file that does not exist +rm -rf sample1-does-not-exist +if ./examples/sftpclient/wolfsftp -u jill -P upthehill -p "$PORT" \ + -G -l sample1-copy.txt -r sample1-does-not-exist +then + echo "Success when expecting fail to get file." + do_cleanup + exit 1 +fi + # Put test. if ! ./examples/sftpclient/wolfsftp -u jill -P upthehill -p "$PORT" \ -g -l sample2.txt -r sample2-copy.txt diff --git a/src/wolfsftp.c b/src/wolfsftp.c index 4817fa26..ae79e3e2 100644 --- a/src/wolfsftp.c +++ b/src/wolfsftp.c @@ -5302,6 +5302,12 @@ static int wolfSSH_SFTP_DoStatus(WOLFSSH* ssh, word32 reqId, } wolfSSH_SFTP_buffer_seek(buffer, 0, localIdx); + + if (status != WOLFSSH_FTP_OK && + ssh->error != WS_WANT_READ && ssh->error != WS_WANT_WRITE) { + /* set ssh error as the SFTP status not being ok */ + ssh->error = WS_SFTP_STATUS_NOT_OK; + } return status; }