Skip to content

Commit

Permalink
try to close file on socket send failure
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobBarthelmeh committed Nov 8, 2024
1 parent 7130153 commit d288a0d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/wolfscp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d288a0d

Please sign in to comment.