mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
bd9f4fa676
For rationale, see https://github.com/php/php-src/pull/6787 Make extension checks lowercase, add a special case for opcache that has internal name not matching .so filename. Extensions migrated in part 2: * dom * exif * fileinfo * ffi
62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
--TEST--
|
|
Bug #77632 (FFI Segfaults When Called With Variadics)
|
|
--EXTENSIONS--
|
|
ffi
|
|
--SKIPIF--
|
|
<?php
|
|
try {
|
|
$libc = FFI::cdef("int printf(const char *format, ...);", "libc.so.6");
|
|
} catch (Throwable $_) {
|
|
die('skip libc.so.6 not available');
|
|
}
|
|
?>
|
|
--INI--
|
|
ffi.enable=1
|
|
--FILE--
|
|
<?php
|
|
$header = '
|
|
typedef struct _IO_FILE FILE;
|
|
extern FILE *stdout;
|
|
extern FILE *stdin;
|
|
extern FILE *stderr;
|
|
|
|
typedef uint64_t time_t;
|
|
typedef uint32_t pid_t;
|
|
|
|
time_t time(time_t*);
|
|
pid_t getpid(void);
|
|
int fprintf(FILE *, const char *, ...);
|
|
';
|
|
|
|
$ffi = FFI::cdef($header, 'libc.so.6');
|
|
|
|
try {
|
|
$ffi->time();
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage() . "\n";
|
|
}
|
|
|
|
try {
|
|
$ffi->time(null, null);
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage() . "\n";
|
|
}
|
|
|
|
try {
|
|
$ffi->fprintf($ffi->stdout);
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage() . "\n";
|
|
}
|
|
|
|
try {
|
|
$ffi->fprintf($ffi->stdout, 123, "Hello %s\n", "World");
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage() . "\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
FFI\Exception: Incorrect number of arguments for C function 'time', expecting exactly 1 parameter
|
|
FFI\Exception: Incorrect number of arguments for C function 'time', expecting exactly 1 parameter
|
|
FFI\Exception: Incorrect number of arguments for C function 'fprintf', expecting at least 2 parameters
|
|
FFI\Exception: Passing incompatible argument 2 of C function 'fprintf', expecting 'char*', found PHP 'int'
|