Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fix #81223: flock() only locks first byte of file
This commit is contained in:
Christoph M. Becker 2021-07-06 11:59:41 +02:00
commit d776413f0b
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
3 changed files with 28 additions and 1 deletions

3
NEWS
View File

@ -32,6 +32,9 @@ PHP NEWS
. Fixed bug #81208 (Segmentation fault while create newInstance from
attribute). (Nikita)
- Standard:
. Fixed bug #81223 (flock() only locks first byte of file). (cmb)
17 Jun 2021, PHP 8.0.8
- Core:

View File

@ -103,7 +103,7 @@ PHPAPI int php_flock(int fd, int operation)
*/
{
HANDLE hdl = (HANDLE) _get_osfhandle(fd);
DWORD low = 1, high = 0;
DWORD low = 0xFFFFFFFF, high = 0xFFFFFFFF;
OVERLAPPED offset =
{0, 0, 0, 0, NULL};
DWORD err;

View File

@ -0,0 +1,24 @@
--TEST--
Bug #81223 (flock() only locks first byte of file)
--SKIPIF--
<?php
if (PHP_OS_FAMILY !== "Windows") die("skip for Windows only");
?>
--FILE--
<?php
$filename = __FILE__;
$stream1 = fopen($filename, "r");
var_dump(flock($stream1, LOCK_EX));
$stream2 = fopen($filename, "r");
var_dump(fread($stream2, 5));
fseek($stream2, 1);
var_dump(fread($stream2, 4));
?>
--EXPECTF--
bool(true)
Notice: fread(): read of %d bytes failed with errno=13 Permission denied in %s on line %d
bool(false)
Notice: fread(): read of %d bytes failed with errno=13 Permission denied in %s on line %d
bool(false)