Skip to content

Commit d7de73b

Browse files
authored
Fix overflow check in OnUpdateMemoryConsumption (#10456)
memsize is a signed long, therefore the check against the (*un*signed long maximum) / 1024² will allow too large values. This check worked correctly in d4b3f89 where it checked against the maximum signed value, but was broken in 003346c. Fix it by changing ZEND_ULONG_MAX to ZEND_LONG_MAX.
1 parent 1173c2e commit d7de73b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/opcache/zend_accelerator_module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
7070
zend_accel_error(ACCEL_LOG_WARNING, "opcache.memory_consumption is set below the required 8MB.\n");
7171
return FAILURE;
7272
}
73-
if (UNEXPECTED(memsize > ZEND_ULONG_MAX / (1024 * 1024))) {
74-
*p = ZEND_ULONG_MAX;
73+
if (UNEXPECTED(memsize > ZEND_LONG_MAX / (1024 * 1024))) {
74+
*p = ZEND_LONG_MAX;
7575
} else {
7676
*p = memsize * (1024 * 1024);
7777
}

0 commit comments

Comments
 (0)