ftp: use SSL_write_ex() in single_send() to fix signed/unsigned handling - #22967
Open
crystarm wants to merge 2 commits into
Open
ftp: use SSL_write_ex() in single_send() to fix signed/unsigned handling#22967crystarm wants to merge 2 commits into
crystarm wants to merge 2 commits into
Conversation
Replace SSL_write() with SSL_write_ex() and pass its return value to SSL_get_error(). This preserves the original API contract and avoids signed/unsigned conversion issues when handling errors. Signed-off-by: Denis Sergeev <zeff@altlinux.org>
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 continues #19912, adding a fix for the outstanding review comment from @ndossche that hadn't been addressed yet.
The first commit here (by @zeff-ir) replaces
SSL_write()withSSL_write_ex(), which reports success/failure via its ownintreturn value while writing the number of bytes sent through a separatesize_t*out-parameter — avoiding the conversion issue entirely and matching the OpenSSL API contract.The second commit finishes the fix requested in review:
single_send()still narrowed its result tointon return (return (int)sent;), even though it now computes asize_t(fromSSL_write_ex()) or anssize_t(frommy_send_wrapper_with_restart()in the non-SSL path). Returningssize_tinstead avoids a theoretical truncation/overflow for writes larger thanINT_MAX, which could otherwise collide with the-1error sentinel checked by the caller (my_send()) or corrupt its buffer pointer arithmetic.In case this PR is accepted, #19912 should be closed.