Repository navigation
Conversation
Contributor
|
Looks good to me. Does this need a line in |
devnexen
reviewed
Aug 29, 2026
Member
|
change is good but do not forget to add UPGRADING entry ;) |
…ct/ftp_ssl_connect $port was parsed as zend_long but cast to C short before being passed to ftp_open(). Values outside 0-65535 silently connected to a different port (their low 16 bits), e.g. 65536 -> 0 -> 21, and 2121+2**32 -> 2121. Add a range guard (must be between 0 and 65535) in both ftp_connect() and ftp_ssl_connect() before the connection attempt, consistent with the existing timeout guards a few lines below. Fixes: #758
Presuming ValueError in the catch would let a change of thrown class slip through; the class is now printed and asserted alongside the message.
lacatoire
force-pushed
the
fix/ftp-connect-port-range
branch
from
November 12, 2026 08:02
fe3521f to
84f2dcd
Compare
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.
ftp_connect()andftp_ssl_connect()accept$portaszend_longbut cast it to Cshortat theftp_open()call site without range-checking first. Values outside 0–65535 silently wrap:65536narrows to0, whichftp_open()rewrites to21, connecting to the FTP control port regardless of what the caller requested.The fix validates
$portbefore the cast and throws aValueErrorfor out-of-range values, consistent with how other extensions handle integer narrowing.A test covering the boundary and the silent-wrap case is added.