mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-14215: Cannot use FFI::load on CRLF header file with apache2handler
This commit is contained in:
commit
889f308e01
@ -3283,7 +3283,11 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */
|
||||
|
||||
code_size = buf.st_size;
|
||||
code = emalloc(code_size + 1);
|
||||
fd = open(filename, O_RDONLY, 0);
|
||||
int open_flags = O_RDONLY;
|
||||
#ifdef PHP_WIN32
|
||||
open_flags |= _O_BINARY;
|
||||
#endif
|
||||
fd = open(filename, open_flags, 0);
|
||||
if (fd < 0 || read(fd, code, code_size) != code_size) {
|
||||
if (preload) {
|
||||
zend_error(E_WARNING, "FFI: Failed pre-loading '%s', cannot read_file", filename);
|
||||
|
3
ext/ffi/tests/gh14215.h
Normal file
3
ext/ffi/tests/gh14215.h
Normal file
@ -0,0 +1,3 @@
|
||||
#define FFI_LIB "Kernel32.dll"
|
||||
typedef unsigned long DWORD;
|
||||
DWORD GetLastError(void);
|
23
ext/ffi/tests/gh14215.phpt
Normal file
23
ext/ffi/tests/gh14215.phpt
Normal file
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
GH-14215 (Cannot use FFI::load on CRLF header file with apache2handler)
|
||||
--EXTENSIONS--
|
||||
ffi
|
||||
zend_test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(PHP_OS_FAMILY !== "Windows") {
|
||||
die('skip only for Windows');
|
||||
}
|
||||
?>
|
||||
--INI--
|
||||
ffi.enable=1
|
||||
--FILE--
|
||||
<?php
|
||||
zend_test_set_fmode(false);
|
||||
$header_path = __DIR__.'\\gh14215.h';
|
||||
$ffi = FFI::load($header_path);
|
||||
var_dump($ffi->GetLastError());
|
||||
zend_test_set_fmode(true);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
@ -739,6 +739,18 @@ static ZEND_FUNCTION(zend_test_is_pcre_bundled)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
static ZEND_FUNCTION(zend_test_set_fmode)
|
||||
{
|
||||
bool binary;
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_BOOL(binary)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
_fmode = binary ? _O_BINARY : _O_TEXT;
|
||||
}
|
||||
#endif
|
||||
|
||||
static zend_object *zend_test_class_new(zend_class_entry *class_type)
|
||||
{
|
||||
zend_object *obj = zend_objects_new(class_type);
|
||||
|
@ -275,6 +275,10 @@ function zend_test_override_libxml_global_state(): void {}
|
||||
#endif
|
||||
|
||||
function zend_test_is_pcre_bundled(): bool {}
|
||||
|
||||
#if defined(PHP_WIN32)
|
||||
function zend_test_set_fmode(bool $binary): void {}
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace ZendTestNS {
|
||||
|
14
ext/zend_test/test_arginfo.h
generated
14
ext/zend_test/test_arginfo.h
generated
@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 1f258f37425d3f6458c447ac2e7b3cbe0a221be0 */
|
||||
* Stub hash: 53027610adee7e1c675b1c1b38886100ce4e63ef */
|
||||
|
||||
ZEND_STATIC_ASSERT(PHP_VERSION_ID >= 80000, "test_arginfo.h only supports PHP version ID 80000 or newer, "
|
||||
"but it is included on an older PHP version");
|
||||
@ -147,6 +147,12 @@ ZEND_END_ARG_INFO()
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_is_pcre_bundled, 0, 0, _IS_BOOL, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#if defined(PHP_WIN32)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_set_fmode, 0, 1, IS_VOID, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, binary, _IS_BOOL, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
||||
#define arginfo_ZendTestNS2_namespaced_func arginfo_zend_test_is_pcre_bundled
|
||||
|
||||
#define arginfo_ZendTestNS2_namespaced_deprecated_func arginfo_zend_test_void_return
|
||||
@ -268,6 +274,9 @@ static ZEND_FUNCTION(get_open_basedir);
|
||||
static ZEND_FUNCTION(zend_test_override_libxml_global_state);
|
||||
#endif
|
||||
static ZEND_FUNCTION(zend_test_is_pcre_bundled);
|
||||
#if defined(PHP_WIN32)
|
||||
static ZEND_FUNCTION(zend_test_set_fmode);
|
||||
#endif
|
||||
static ZEND_FUNCTION(ZendTestNS2_namespaced_func);
|
||||
static ZEND_FUNCTION(ZendTestNS2_namespaced_deprecated_func);
|
||||
static ZEND_FUNCTION(ZendTestNS2_ZendSubNS_namespaced_func);
|
||||
@ -360,6 +369,9 @@ static const zend_function_entry ext_functions[] = {
|
||||
ZEND_FE(zend_test_override_libxml_global_state, arginfo_zend_test_override_libxml_global_state)
|
||||
#endif
|
||||
ZEND_FE(zend_test_is_pcre_bundled, arginfo_zend_test_is_pcre_bundled)
|
||||
#if defined(PHP_WIN32)
|
||||
ZEND_FE(zend_test_set_fmode, arginfo_zend_test_set_fmode)
|
||||
#endif
|
||||
#if (PHP_VERSION_ID >= 80400)
|
||||
ZEND_RAW_FENTRY(ZEND_NS_NAME("ZendTestNS2", "namespaced_func"), zif_ZendTestNS2_namespaced_func, arginfo_ZendTestNS2_namespaced_func, 0, NULL, NULL)
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user