diff --git a/NEWS b/NEWS index 2efb946fded..6493d92179d 100644 --- a/NEWS +++ b/NEWS @@ -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: diff --git a/ext/standard/flock_compat.c b/ext/standard/flock_compat.c index 7b0ad2df23c..da49888b56c 100644 --- a/ext/standard/flock_compat.c +++ b/ext/standard/flock_compat.c @@ -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; diff --git a/ext/standard/tests/file/bug81223.phpt b/ext/standard/tests/file/bug81223.phpt new file mode 100644 index 00000000000..0331d631bc8 --- /dev/null +++ b/ext/standard/tests/file/bug81223.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #81223 (flock() only locks first byte of file) +--SKIPIF-- + +--FILE-- + +--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)