Skip to content

Commit a681b12

Browse files
committed
Fix #79427: Integer Overflow in shmop_open()
If `shm.shm_segsz > ZEND_LONG_MAX` the assignment to `shmop->size` a few lines below would overflow, so we catch that early and bail out if necessary.
1 parent 0492064 commit a681b12

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ PHP NEWS
2020
. Fixed bug #79412 (Opcache chokes and uses 100% CPU on specific script).
2121
(Dmitry)
2222

23+
- Shmop:
24+
. Fixed bug #79427 (Integer Overflow in shmop_open()). (cmb)
25+
2326
- SimpleXML:
2427
. Fixed bug #61597 (SXE properties may lack attributes and content). (cmb)
2528

ext/shmop/shmop.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ PHP_FUNCTION(shmop_open)
207207
goto err;
208208
}
209209

210+
if (shm.shm_segsz > ZEND_LONG_MAX) {
211+
php_error_docref(NULL, E_WARNING, "shared memory segment too large to attach");
212+
goto err;
213+
}
214+
210215
shmop->addr = shmat(shmop->shmid, 0, shmop->shmatflg);
211216
if (shmop->addr == (char*) -1) {
212217
php_error_docref(NULL, E_WARNING, "unable to attach to shared memory segment '%s'", strerror(errno));

0 commit comments

Comments
 (0)