mirror of https://github.com/wolfSSL/wolfssh.git
add check for channel eof and remove shutdown call
parent
796a745a92
commit
981a506967
|
@ -314,7 +314,7 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args)
|
|||
err_sys("Sending the shutdown messages failed.");
|
||||
}
|
||||
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.");
|
||||
}
|
||||
WCLOSESOCKET(sockFd);
|
||||
|
|
|
@ -104,7 +104,7 @@ int DoScpSink(WOLFSSH* ssh)
|
|||
|
||||
if ( (ret = ReceiveScpMessage(ssh)) < WS_SUCCESS) {
|
||||
if (ret == WS_EOF) {
|
||||
ret = wolfSSH_shutdown(ssh);
|
||||
ret = WS_SUCCESS; /* successfully recieved message */
|
||||
ssh->scpState = SCP_DONE;
|
||||
break;
|
||||
}
|
||||
|
@ -1370,6 +1370,17 @@ int ReceiveScpMessage(WOLFSSH* ssh)
|
|||
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);
|
||||
|
||||
/* null-terminate request, replace newline */
|
||||
|
|
Loading…
Reference in New Issue