From d288a0deb2175bee82983ea3f3d426ae44b166fe Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Fri, 8 Nov 2024 11:18:41 -0700 Subject: [PATCH] try to close file on socket send failure --- src/wolfscp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/wolfscp.c b/src/wolfscp.c index 1be04b2af..5e35fee0c 100644 --- a/src/wolfscp.c +++ b/src/wolfscp.c @@ -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; }