Bug #81223 [Asn->Csd]: flock() only locks first byte of file

From: Date: Tue, 06 Jul 2021 10:04:39 +0000
Subject: Bug #81223 [Asn->Csd]: flock() only locks first byte of file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234810@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81223&edit=1 ID: 81223 Updated by: git@php.net Reported by: cmb@php.net Summary: flock() only locks first byte of file -Status: Assigned +Status: Closed Type: Bug Package: Filesystem function related Operating System: Windows PHP Version: 7.4Git-2021-07-05 (Git) Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmb69 Revision: https://github.com/php/php-src/commit/520c00a5bffd87a5318c487bf1b778a53e8298d4 Log: Fix #81223: flock() only locks first byte of file Previous Comments: ------------------------------------------------------------------------ [2021-07-05 14:14:47] cmb@php.net 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 this bug report at https://bugs.php.net/bug.php?id=81223&edit=1

« previous php.bugs (#234810) next »