Skip to content

ftp: use SSL_write_ex() in single_send() to fix signed/unsigned handling - #22967

Open
crystarm wants to merge 2 commits into
php:masterfrom
crystarm:fix/ftp-ssl-write-truncation
Open

ftp: use SSL_write_ex() in single_send() to fix signed/unsigned handling#22967
crystarm wants to merge 2 commits into
php:masterfrom
crystarm:fix/ftp-ssl-write-truncation

Conversation

@crystarm

Copy link
Copy Markdown
Contributor

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() with SSL_write_ex(), which reports success/failure via its own int return value while writing the number of bytes sent through a separate size_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 to int on return (return (int)sent;), even though it now computes a size_t (from SSL_write_ex()) or an ssize_t (from my_send_wrapper_with_restart() in the non-SSL path). Returning ssize_t instead avoids a theoretical truncation/overflow for writes larger than INT_MAX, which could otherwise collide with the -1 error sentinel checked by the caller (my_send()) or corrupt its buffer pointer arithmetic.

In case this PR is accepted, #19912 should be closed.

zeff-ir and others added 2 commits October 13, 2025 13:37
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants