Skip to content

Commit a3abcc0

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #81223: flock() only locks first byte of file
2 parents 909e134 + d776413 commit a3abcc0

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

ext/standard/flock_compat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ PHPAPI int php_flock(int fd, int operation)
103103
*/
104104
{
105105
HANDLE hdl = (HANDLE) _get_osfhandle(fd);
106-
DWORD low = 1, high = 0;
106+
DWORD low = 0xFFFFFFFF, high = 0xFFFFFFFF;
107107
OVERLAPPED offset =
108108
{0, 0, 0, 0, NULL};
109109
DWORD err;

ext/standard/tests/file/bug81223.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #81223 (flock() only locks first byte of file)
3+
--SKIPIF--
4+
<?php
5+
if (PHP_OS_FAMILY !== "Windows") die("skip for Windows only");
6+
?>
7+
--FILE--
8+
<?php
9+
$filename = __FILE__;
10+
$stream1 = fopen($filename, "r");
11+
var_dump(flock($stream1, LOCK_EX));
12+
$stream2 = fopen($filename, "r");
13+
var_dump(fread($stream2, 5));
14+
fseek($stream2, 1);
15+
var_dump(fread($stream2, 4));
16+
?>
17+
--EXPECTF--
18+
bool(true)
19+
20+
Notice: fread(): read of %d bytes failed with errno=13 Permission denied in %s on line %d
21+
bool(false)
22+
23+
Notice: fread(): read of %d bytes failed with errno=13 Permission denied in %s on line %d
24+
bool(false)

0 commit comments

Comments
 (0)