add check for channel eof and remove shutdown call

pull/519/head
JacobBarthelmeh 2023-06-01 15:05:24 -07:00
parent 796a745a92
commit 981a506967
2 changed files with 13 additions and 2 deletions

View File

@ -314,7 +314,7 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args)
err_sys("Sending the shutdown messages failed."); err_sys("Sending the shutdown messages failed.");
} }
ret = wolfSSH_worker(ssh, NULL); ret = wolfSSH_worker(ssh, NULL);
if (ret != WS_SUCCESS) { if (ret != WS_SUCCESS && ret != WS_CHANNEL_CLOSED) {
err_sys("Failed to listen for close messages from the peer."); err_sys("Failed to listen for close messages from the peer.");
} }
WCLOSESOCKET(sockFd); WCLOSESOCKET(sockFd);

View File

@ -104,7 +104,7 @@ int DoScpSink(WOLFSSH* ssh)
if ( (ret = ReceiveScpMessage(ssh)) < WS_SUCCESS) { if ( (ret = ReceiveScpMessage(ssh)) < WS_SUCCESS) {
if (ret == WS_EOF) { if (ret == WS_EOF) {
ret = wolfSSH_shutdown(ssh); ret = WS_SUCCESS; /* successfully recieved message */
ssh->scpState = SCP_DONE; ssh->scpState = SCP_DONE;
break; break;
} }
@ -1370,6 +1370,17 @@ int ReceiveScpMessage(WOLFSSH* ssh)
return err; return err;
} }
} }
/* check if wolfSSH_worker returns 0 from handling a channel eof */
if (err == 0) {
WOLFSSH_CHANNEL* channel;
channel = wolfSSH_ChannelFind(ssh, lastChannel, WS_CHANNEL_ID_SELF);
if (channel == NULL)
ret = WS_INVALID_CHANID;
if (wolfSSH_ChannelGetEof(channel)) {
return WS_EOF;
}
}
} while (sz == 0 || buf[sz - 1] != 0x0a); } while (sz == 0 || buf[sz - 1] != 0x0a);
/* null-terminate request, replace newline */ /* null-terminate request, replace newline */