mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79566: Private SHM is not private on Windows
This commit is contained in:
commit
e749db4047
@ -613,14 +613,16 @@ TSRM_API int shmget(key_t key, size_t size, int flags)
|
||||
{/*{{{*/
|
||||
shm_pair *shm;
|
||||
char shm_segment[26], shm_info[29];
|
||||
HANDLE shm_handle, info_handle;
|
||||
HANDLE shm_handle = NULL, info_handle = NULL;
|
||||
BOOL created = FALSE;
|
||||
|
||||
snprintf(shm_segment, sizeof(shm_segment), "TSRM_SHM_SEGMENT:%d", key);
|
||||
snprintf(shm_info, sizeof(shm_info), "TSRM_SHM_DESCRIPTOR:%d", key);
|
||||
if (key != IPC_PRIVATE) {
|
||||
snprintf(shm_segment, sizeof(shm_segment), "TSRM_SHM_SEGMENT:%d", key);
|
||||
snprintf(shm_info, sizeof(shm_info), "TSRM_SHM_DESCRIPTOR:%d", key);
|
||||
|
||||
shm_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_segment);
|
||||
info_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_info);
|
||||
shm_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_segment);
|
||||
info_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_info);
|
||||
}
|
||||
|
||||
if (!shm_handle && !info_handle) {
|
||||
if (flags & IPC_CREAT) {
|
||||
@ -631,8 +633,8 @@ TSRM_API int shmget(key_t key, size_t size, int flags)
|
||||
DWORD high = 0;
|
||||
DWORD low = size;
|
||||
#endif
|
||||
shm_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, high, low, shm_segment);
|
||||
info_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(shm->descriptor), shm_info);
|
||||
shm_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, high, low, key == IPC_PRIVATE ? NULL : shm_segment);
|
||||
info_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(shm->descriptor), key == IPC_PRIVATE ? NULL : shm_info);
|
||||
created = TRUE;
|
||||
}
|
||||
if (!shm_handle || !info_handle) {
|
||||
|
23
ext/shmop/tests/shmop_open_private.phpt
Normal file
23
ext/shmop/tests/shmop_open_private.phpt
Normal file
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
shmop_open with IPC_PRIVATE creates private SHM
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('shmop')) die('skip shmop extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$write = 'test';
|
||||
|
||||
$shm1 = shmop_open(0, 'c', 0777, 1024);
|
||||
shmop_write($shm1, $write, 0);
|
||||
|
||||
$shm2 = shmop_open(0, 'c', 0777, 1024);
|
||||
$read = shmop_read($shm2, 0, 4);
|
||||
|
||||
var_dump(is_string($read) && $read !== $write);
|
||||
|
||||
shmop_close($shm1);
|
||||
shmop_close($shm2);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
Loading…
Reference in New Issue
Block a user