try to close file on socket send failure

pull/750/head
JacobBarthelmeh 2024-11-08 11:18:41 -07:00
parent 71301530a1
commit d288a0deb2
1 changed files with 9 additions and 0 deletions

View File

@ -610,6 +610,15 @@ int DoScpSource(WOLFSSH* ssh)
continue;
}
if (ret < 0) {
#if !defined(NO_FILESYSTEM) && \
!defined(WOLFSSH_SCP_USER_CALLBACKS)
/* if the socket send had a fatal error, try to close any
* open file descriptor before exit */
ScpSendCtx* sendCtx = NULL;
sendCtx = (ScpSendCtx*)wolfSSH_GetScpSendCtx(ssh);
if (sendCtx != NULL)
WFCLOSE(ssh->fs, sendCtx->fp);
#endif
WLOG(WS_LOG_ERROR, scpError, "failed to send file", ret);
break;
}