Browse Source

Issue 2395 – Incomplete FTP upload when the source stream/stdin reads less than requested

https://winscp.net/tracker/2395

Source commit: 2577e5f6685b0dc1d31130283bbe94e82514f71b
Martin Prikryl 2 months ago
parent
commit
178d063da0
1 changed files with 5 additions and 3 deletions
  1. 5 3
      source/filezilla/TransferSocket.cpp

+ 5 - 3
source/filezilla/TransferSocket.cpp

@@ -587,9 +587,11 @@ void CTransferSocket::OnSend(int nErrorCode)
         CloseOnShutDownOrError(CSMODE_TRANSFERERROR);
         return;
       }
-      else if (!pos && // all data in buffer were sent
-               numread < readwanted && // was read less then wanted (eof reached?)
-               m_bufferpos != currentBufferSize) // and it's not because the buffer is full?
+      else if ((pos == 0) && // all data in buffer were sent
+               // was read less then wanted (eof reached?)
+               // (should be safe to always just do (numread <= 0), but limiting the impact of the change for now)
+               (numread < ((m_OnTransferIn != NULL) ? 1 : readwanted)) &&
+               (m_bufferpos != currentBufferSize)) // and it's not because the buffer is full?
       {
         // With TLS 1.3 we can get back
         m_bufferpos = 0;