From 7f55d888a8d9f9c94048ce43f2d8c820f2448954 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Mon, 4 May 2020 13:31:21 -0700 Subject: [PATCH] SCP Disconnect 1. When receiving the EOF from the client, wolfSCP should be shutting down the connection. 2. When shutting down the connection, don't send Disconnect. Instead send channel exit, then follow with close. This tells the client that the program exited cleanly. --- src/ssh.c | 4 ++-- src/wolfscp.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ssh.c b/src/ssh.c index d97a59e..d9665ab 100644 --- a/src/ssh.c +++ b/src/ssh.c @@ -868,10 +868,10 @@ int wolfSSH_shutdown(WOLFSSH* ssh) ret = SendChannelEof(ssh, ssh->channelList->peerChannel); if (ret == WS_SUCCESS) - ret = SendChannelClose(ssh, ssh->channelList->peerChannel); + ret = SendChannelExit(ssh, ssh->channelList->peerChannel, 0); if (ret == WS_SUCCESS) - ret = SendDisconnect(ssh, WOLFSSH_DISCONNECT_BY_APPLICATION); + ret = SendChannelClose(ssh, ssh->channelList->peerChannel); if (ssh != NULL && ssh->channelList == NULL) { WLOG(WS_LOG_DEBUG, "channel list was already removed"); diff --git a/src/wolfscp.c b/src/wolfscp.c index 2019dd3..b972eec 100644 --- a/src/wolfscp.c +++ b/src/wolfscp.c @@ -85,7 +85,7 @@ int DoScpSink(WOLFSSH* ssh) if ( (ret = ReceiveScpMessage(ssh)) < WS_SUCCESS) { if (ret == WS_EOF) { - ret = WS_SUCCESS; + ret = wolfSSH_shutdown(ssh); ssh->scpState = SCP_DONE; break; }