issue-576: Fix SSL uploads corruption when using Unix curl passive mode#663
Open
Pandiyarajk wants to merge 1 commit into
Open
issue-576: Fix SSL uploads corruption when using Unix curl passive mode#663Pandiyarajk wants to merge 1 commit into
Pandiyarajk wants to merge 1 commit into
Conversation
…ve mode This commit addresses issue giampaolo#576 where Unix curl FTP uploads over SSL/TLS resulted in corrupted zip files. The root cause was premature SSL shutdown during active data transfers. **Problem:** When `OpenSSL.SSL.ZeroReturnError` occurred in `SSLConnection.recv()` during an active file transfer, the connection would immediately close via `super().handle_close()`, causing incomplete file writes and corruption. **Solution:** Modified `SSLConnection.recv()` to defer connection closure when a file transfer is in progress. If `file_obj` exists (indicating active transfer), the method returns `b''` instead of closing the connection immediately. **Changes:** - Modified `SSLConnection.recv()` to check for active file transfers before closing on `SSL.ZeroReturnError` - Added `TLS_DTPHandler.close()` override to ensure proper SSL shutdown - Cleaned up incorrect SSL buffer handling in `FTPHandler.on_file_received()` **Testing:** The fix prevents premature SSL shutdown during file transfers while maintaining proper connection cleanup after transfer completion. This resolves the specific corruption issue reported in giampaolo#576. Note: This addresses the SSL-specific corruption issue. Broader 0-byte transfer problems observed during testing are separate and require additional investigation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit addresses issue #576 where Unix curl FTP uploads over SSL/TLS resulted in corrupted zip files. The root cause was premature SSL shutdown during active data transfers.
Problem:
When
OpenSSL.SSL.ZeroReturnErroroccurred inSSLConnection.recv()during an active file transfer, the connection would immediately close viasuper().handle_close(), causing incomplete file writes and corruption.Solution:
Modified
SSLConnection.recv()to defer connection closure when a file transfer is in progress. Iffile_objexists (indicating active transfer), the method returnsb''instead of closing the connection immediately.Changes:
SSLConnection.recv()to check for active file transfers before closing onSSL.ZeroReturnErrorTLS_DTPHandler.close()override to ensure proper SSL shutdownFTPHandler.on_file_received()Testing:
The fix prevents premature SSL shutdown during file transfers while maintaining proper connection cleanup after transfer completion. This resolves the specific corruption issue reported in #576.
Note: This addresses the SSL-specific corruption issue. Broader 0-byte transfer problems observed during testing are separate and require additional investigation.