Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Zend/tests/arginfo_zpp_mismatch.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ if (getenv('SKIP_MSAN')) die("skip msan misses interceptors for some functions")

require __DIR__ . "/arginfo_zpp_mismatch.inc";

function testWeakSysvIpcFunction($function): bool {
if (!in_array($function, ['msg_queue_exists', 'msg_get_queue', 'sem_get', 'shm_attach'], true)) {
return false;
}

for ($argumentCount = 0; $argumentCount <= 8; $argumentCount++) {
$arguments = array_fill(0, $argumentCount, null);
if ($function === 'msg_queue_exists' && $argumentCount >= 1) {
$arguments[0] = 1;
}
if (($function === 'sem_get' || $function === 'shm_attach') && $argumentCount >= 3) {
$arguments[2] = 0600;
}

try {
$result = @$function(...$arguments);
if ($result instanceof SysvMessageQueue) {
msg_remove_queue($result);
} elseif ($result instanceof SysvSemaphore) {
sem_remove($result);
} elseif ($result instanceof SysvSharedMemory) {
shm_remove($result);
}
} catch (Throwable) {
}
}

return true;
}

function test($function) {
if (skipFunction($function)) {
return;
Expand All @@ -21,6 +51,10 @@ function test($function) {
} else {
echo "Testing " . get_class($function[0]) . "::$function[1]\n";
}
if (testWeakSysvIpcFunction($function)) {
ob_end_clean();
return;
}
try {
@$function();
} catch (Throwable) {
Expand Down
4 changes: 3 additions & 1 deletion ext/sysvmsg/tests/gh16592.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ class Test {
function __serialize() {}
}

$q = msg_get_queue(1);
// use a private queue, so we only remove our own.
$q = msg_get_queue(0, 0600);
try {
msg_send($q, 1, new Test, true);
} catch (\TypeError $e) {
echo $e->getMessage();
}
msg_remove_queue($q);
?>
--EXPECT--
Test::__serialize() must return an array
Loading