Skip to content

Commit 443d150

Browse files
committed
Fix int truncation of read length in shmop_read()
shmop_read() held the read length in an int while count and shmop->size are zend_long and the bounds checks above validate against the full 64-bit size. On a shared-memory segment larger than INT_MAX a read whose length sets the int sign bit was sign-extended into the size_t length argument of zend_string_init(), requesting a near-SIZE_MAX allocation; other truncated lengths silently returned a wrong-sized string. Hold the length in a zend_long, matching the zend_long writesize already used in shmop_write().
1 parent 19f595f commit 443d150

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

ext/shmop/shmop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ PHP_FUNCTION(shmop_read)
224224
zend_long start, count;
225225
php_shmop *shmop;
226226
char *startaddr;
227-
int bytes;
227+
zend_long bytes;
228228
zend_string *return_string;
229229

230230
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &shmid, shmop_ce, &start, &count) == FAILURE) {

0 commit comments

Comments
 (0)