Skip to content

Commit 4631e9d

Browse files
committed
shmget() with IPC_CREAT must not create 0 size SHM
The recently committed fix for GH-9944 did only indirectly cater to that, namely because in this case `CreateFileMapping()` with a zero size couldn't be created. As of PHP 8.2.0, the mappings of the actual SHM and the info segment have been merged, so creating a zero size SHM would be possible unless we explicitly prohibit this.
1 parent 9089e15 commit 4631e9d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

TSRM/tsrm_win32.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ TSRM_API int shmget(key_t key, size_t size, int flags)
645645

646646
if (!shm_handle) {
647647
if (flags & IPC_CREAT) {
648-
if (size > SIZE_MAX - sizeof(shm->descriptor)) {
648+
if (size == 0 || size > SIZE_MAX - sizeof(shm->descriptor)) {
649649
return -1;
650650
}
651651
size += sizeof(shm->descriptor);

0 commit comments

Comments
 (0)