Files
php-src/ext/sysvmsg/tests/msg_queue_ipc_private.phpt
Ilia Alshanetsky a0d06f1c29 sysvmsg/sysvsem: fix IPC_PRIVATE and out-of-range key handling (#22956)
msgget() always creates a queue for IPC_PRIVATE, so the existence probe
in msg_queue_exists() leaks one per call, and the same probe in
msg_get_queue() shadows the IPC_CREAT branch and hands back a queue with
no permission bits. Skip the probe for IPC_PRIVATE. msg_queue_exists(),
msg_get_queue() and sem_get() also passed the zend_long key straight to
msgget()/semget(), where it truncates to key_t; they now reject
out-of-range keys as shmop_open() and shm_attach() have since GH-9945.

Closes GH-22956
2026-07-31 16:06:55 -04:00

29 lines
547 B
PHP

--TEST--
msg_queue_exists() and msg_get_queue() with IPC_PRIVATE
--EXTENSIONS--
sysvmsg
--FILE--
<?php
var_dump(msg_queue_exists(0));
$queue = msg_get_queue(0, 0600);
try {
var_dump(msg_queue_exists(0));
printf("%o\n", msg_stat_queue($queue)['msg_perm.mode']);
var_dump(msg_send($queue, 1, 'hello'));
var_dump(msg_receive($queue, 1, $type, 1024, $message));
var_dump($message);
} finally {
var_dump(msg_remove_queue($queue));
}
?>
--EXPECT--
bool(false)
bool(false)
600
bool(true)
bool(true)
string(5) "hello"
bool(true)