Skip to content

Commit d288a0d

Browse files
try to close file on socket send failure
1 parent 7130153 commit d288a0d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/wolfscp.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,15 @@ int DoScpSource(WOLFSSH* ssh)
610610
continue;
611611
}
612612
if (ret < 0) {
613+
#if !defined(NO_FILESYSTEM) && \
614+
!defined(WOLFSSH_SCP_USER_CALLBACKS)
615+
/* if the socket send had a fatal error, try to close any
616+
* open file descriptor before exit */
617+
ScpSendCtx* sendCtx = NULL;
618+
sendCtx = (ScpSendCtx*)wolfSSH_GetScpSendCtx(ssh);
619+
if (sendCtx != NULL)
620+
WFCLOSE(ssh->fs, sendCtx->fp);
621+
#endif
613622
WLOG(WS_LOG_ERROR, scpError, "failed to send file", ret);
614623
break;
615624
}

0 commit comments

Comments
 (0)