-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Cannot use FFI::load on CRLF header file with apache2handler #14215
Comments
Sorry, I accidentally created the issue before writing the description. |
8.1 is closed for bugfixes, so lowest branch we can fix this in is 8.2. I'll have a look today. |
nielsdos
added a commit
to nielsdos/php-src
that referenced
this issue
May 13, 2024
…2handler Some modules may reset _fmode, which causes mangling of line endings. Always be explicit like we do in other places where the native open call is used.
nielsdos
added
OS: Windows
Extension: ffi
Status: Verified
and removed
Status: Needs Triage
labels
May 13, 2024
nielsdos
added a commit
that referenced
this issue
May 14, 2024
* PHP-8.2: Fix GH-14215: Cannot use FFI::load on CRLF header file with apache2handler
nielsdos
added a commit
that referenced
this issue
May 14, 2024
* PHP-8.3: Fix GH-14215: Cannot use FFI::load on CRLF header file with apache2handler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
With this PHP file:
And this header file (saved with CRLF line endings) :
I get this output:
But if I launch the script directly, I get this :
What seems to be happening here is that the
zend_ffi_load
function, which is used byFFI::load()
, usestat
to get the header size, then useopen
andread
to read the file.Then it checks if the byte amount returned from
read
is equal to the file size fromstat
.If it's not, then it throws an error
Failed loading '%s', cannot read_file
.The problem is that the file was opened in
O_TEXT
mode, so line endings were converted from CRLF to LF, and the byte amount returned is lower than expected.I've checked PHP's source code, and it seems that the CGI and CLI
main
functions have some code to set_fmode
to_O_BINARY
, which is probably why I don't get the error when I run the script directly.The
sapi/apache2handler/
folder doesn't seems to have any mention of_fmode
.PHP Version
PHP 8.1.27
Edit : It also happens on PHP 8.3.7.
Operating System
Windows 10
Note that I'm using the WAMP version of PHP.
The text was updated successfully, but these errors were encountered: