Skip to content

Fix #79100: Wrong FTP error messages #6718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Feb 23, 2021

First we need to properly clear the inbuf, what is an amendment to
commit d2881ad[1].

Then we need to report php_pollfd_for_ms() failures right away; just
setting errno does not really help, since at least in some cases it
would have been overwritten before we actually could check it. We use
php_socket_strerror() to get a proper error message, and define
ETIMEDOUT to the proper value on Windows; otherwise we catch the
definition in errno.h, which is not compatible with WinSock. The
proper solution for this issue would likely be to include something
like ext/sockets/windows_common.h.

Finally, we ensure that we only report warnings using inbuf, if it is
not empty.

[1] http://git.php.net/?p=php-src.git;a=commit;h=d2881adcbc9be60de7e7d45a3316b0e11b7eb1e8.

@cmb69 cmb69 added the Bug label Feb 23, 2021
@nikic
Copy link
Member

nikic commented Mar 16, 2021

Test failure looks legit.

@cmb69
Copy link
Member Author

cmb69 commented Mar 16, 2021

Ah, thanks I missed this. I'll have a look.

@cmb69
Copy link
Member Author

cmb69 commented Mar 22, 2021

The test failure appears to be caused by a limitation of the "FTP server". user_auth() is called once, and actually sends two responses for bug37799.phpt. The first one is consumed by the AUTH TLS command, the second one is supposed to be consumed by the fallback AUTH SSL command. However, this patch clears the extra field for each ftp_putcmd(), what explains the test failure (no error message). A real FTP server would send two separate responses, so clearing still seems to be right.

Then again, if I don't debug this, the test usually succeeds, because the sockets are non-blocking, so the second response may actually be read as separate response. I'm going to commit a hack which lets the server sleep between the two responses.

@cmb69
Copy link
Member Author

cmb69 commented Apr 14, 2021

This is supposed to fix https://bugs.php.net/80901 as well.

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this fixes https://bugs.php.net/bug.php?id=80901 as well? That one is about null-termination of the buffer, and I don't really see related changes here.

@cmb69
Copy link
Member Author

cmb69 commented Apr 21, 2021

Ah, you're right; this does not fix https://bugs.php.net/80901.

cmb69 added a commit to cmb69/php-src that referenced this pull request Apr 22, 2021
cmb69 added 5 commits April 27, 2021 18:26
First we need to properly clear the `inbuf`, what is an amendment to
commit d2881ad[1].

Then we need to report `php_pollfd_for_ms()` failures right away; just
setting `errno` does not really help, since at least in some cases it
would have been overwritten before we actually could check it.  We use
`php_socket_strerror()` to get a proper error message, and define
`ETIMEDOUT` to the proper value on Windows; otherwise we catch the
definition in errno.h, which is not compatible with WinSock.  The
proper solution for this issue would likely be to include something
like ext/sockets/windows_common.h.

Finally, we ensure that we only report warnings using `inbuf`, if it is
not empty.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=d2881adcbc9be60de7e7d45a3316b0e11b7eb1e8>.
Apparently, macOS's error string for ETIMEDOUT is "Operation timed out".
@cmb69
Copy link
Member Author

cmb69 commented May 3, 2021

It seems the test failures are unrelated to this patch. Any objections to merge it?

@cmb69 cmb69 closed this in 42c72ef May 3, 2021
@cmb69 cmb69 deleted the cmb/79100 branch May 3, 2021 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants