Bug #81223 [NEW]: flock() only locks first byte of file

From: Date: Mon, 05 Jul 2021 14:14:47 +0000
Subject: Bug #81223 [NEW]: flock() only locks first byte of file
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234803@lists.php.net to get a copy of this message
From: cmb Operating system: Windows PHP version: 7.4Git-2021-07-05 (Git) Package: Filesystem function related Bug Type: Bug Bug description:flock() only locks first byte of file Description: ------------ On Windows, flock() only locks the first byte of the file, so that fseeking beyond that first byte allows accessing the file contents. Test script: --------------- <?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)); ?> Expected result: ---------------- bool(true) bool(false) bool(false) Actual result: -------------- bool(true) bool(false) string(4) "?php" -- Edit bug report at https://bugs.php.net/bug.php?id=81223&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81223&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81223&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81223&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81223&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81223&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81223&r=support Expected behavior: https://bugs.php.net/fix.php?id=81223&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81223&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81223&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81223&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81223&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81223&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81223&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81223&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81223&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81223&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81223&r=mysqlcfg

« previous php.bugs (#234803) next »