mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
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.
This commit is contained in:
@@ -645,7 +645,7 @@ TSRM_API int shmget(key_t key, size_t size, int flags)
|
||||
|
||||
if (!shm_handle) {
|
||||
if (flags & IPC_CREAT) {
|
||||
if (size > SIZE_MAX - sizeof(shm->descriptor)) {
|
||||
if (size == 0 || size > SIZE_MAX - sizeof(shm->descriptor)) {
|
||||
return -1;
|
||||
}
|
||||
size += sizeof(shm->descriptor);
|
||||
|
||||
Reference in New Issue
Block a user