php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81283 shmop can't read beyond 2147483647 bytes
Submitted: 2021-07-23 10:23 UTC Modified: 2021-07-23 15:47 UTC
From: mr dot sol dot 7788 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2021-07-23 10:23 UTC] mr dot sol dot 7788 at gmail dot com
Description:
------------
PHP 7.4.3 (cli)
Zend Engine v3.4.0
Kubuntu (focal) - x86_64
PHP_INT_SIZE:8 
PHP_INT_MAX:9223372036854775807

Created shared memeory with size 28991029248. Write in all diapozon is normal.
Read bigest at position 2147483646 one byte.
shmop_read($shmp, 2147483647, 1)
getted error 
Warning: shmop_read(): count is out of range in


Test script:
---------------
<?php
$KeyShm = ftok(__FILE__, 'a');
$shmp = shmop_open($KeyShm, 'n', 0644, 28991029248);
$WriteRes = shmop_write($shmp, "a", 2147483647);//All ok
$ReadRes1 = shmop_read($shmp, 2147483646, 1);//All ok
$ReadRes2 = shmop_read($shmp, 2147483647, 1);//Error 
//Warning: shmop_read(): count is out of range in
echo "ReadRes2:'".($ReadRes2!==false?$ReadRes2:'false')."' ".PHP_EOL;
shmop_delete($shmp);
shmop_close($shmp);


Expected result:
----------------
ReadRes2:'a'

Actual result:
--------------
ReadRes2:'false'

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-23 10:36 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2021-07-23 10:36 UTC] nikic@php.net
The overflow check incorrectly uses INT_MAX instead of ZEND_LONG_MAX.
 [2021-07-23 10:45 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #81283: shmop_read(): count is out of range
On GitHub:  https://github.com/php/php-src/pull/7301
Patch:      https://github.com/php/php-src/pull/7301.patch
 [2021-07-23 15:47 UTC] cmb@php.net
-Summary: Integer overflow in shmop_read() +Summary: shmop can't read beyond 2147483647 bytes -Assigned To: +Assigned To: cmb
 [2021-07-23 15:53 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/php-src/commit/387c0de98312d576868bf45e8c7b2d4f2ab3c738
Log: Fix #81283: shmop can't read beyond 2147483647 bytes
 [2021-07-23 15:53 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 18:03:38 2021 UTC