Skip to content

Commit c3aaa6e

Browse files
adjust scp error return checking for closed channels
1 parent 11f0b22 commit c3aaa6e

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

examples/scpclient/scpclient.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,10 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args)
324324
WCLOSESOCKET(sockFd);
325325
wolfSSH_free(ssh);
326326
wolfSSH_CTX_free(ctx);
327-
if (ret != WS_SUCCESS && ret != WS_SOCKET_ERROR_E)
327+
if (ret != WS_SUCCESS && ret != WS_SOCKET_ERROR_E &&
328+
ret != WS_CHANNEL_CLOSED) {
328329
err_sys("Closing scp stream failed. Connection could have been closed by peer");
330+
}
329331

330332
ClientFreeBuffers(pubKeyName, privKeyName, NULL);
331333
#if !defined(WOLFSSH_NO_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS)

src/wolfscp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,11 @@ int DoScpRequest(WOLFSSH* ssh)
730730
/* Peer MUST send back a SSH_MSG_CHANNEL_CLOSE unless already
731731
sent*/
732732
ret = wolfSSH_stream_read(ssh, buf, 1);
733-
if (ret != WS_EOF) {
733+
if (ret == WS_SOCKET_ERROR_E || ret == WS_CHANNEL_CLOSED) {
734+
WLOG(WS_LOG_DEBUG, scpState, "Peer hung up, but SCP is done");
735+
ret = WS_SUCCESS;
736+
}
737+
else if (ret != WS_EOF) {
734738
WLOG(WS_LOG_DEBUG, scpState, "Did not receive EOF packet");
735739
}
736740
else {

0 commit comments

Comments
 (0)