|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46673 stream_lock call with wrong paramater
Submitted: 2008-11-26 03:07 UTC Modified: 2017-08-28 08:23 UTC
From: kaz at e-2 dot co dot jp Assigned: requinix (profile)
Status: Closed Package: Streams related
PHP Version: 5.2.6 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: kaz at e-2 dot co dot jp
New email:
PHP Version: OS:


 [2008-11-26 03:07 UTC] kaz at e-2 dot co dot jp
When i regist my own stream class, and use flock($h, LOCK_UN).
then steam_lock caled with undefined mode(0x8).

321 static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN };
348 act = flock_values[act - 1] | (operation & 4 ? LOCK_NB : 0);
349 if (php_stream_lock(stream, act)) {

Reproduce code:
class StreamTest
    function stream_open($path, $mode, $options, &$opened_path) {
		return true;
    function stream_close() {
		return ;
    function stream_lock($mode) {       
		printf( "0x%x\n", $mode ) ;
        return ;
stream_register_wrapper("streamtest", "StreamTest");
$handle = fopen( 'streamtest://test', "r" ) ;
flock( $handle, LOCK_EX ) ;
flock( $handle, LOCK_UN ) ;
fclose($handle) ;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-26 04:20 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

 [2014-08-16 15:38 UTC] shabazzk at gmail dot com
This bug has resurfaced and I have found this bug in PHP versions 5.3.29, 5.5.15, and 5.6RC4.
 [2017-08-28 08:16 UTC] adolph dot bauer2 at gmail dot com
I found this bug to be reproducable in PHP version 7.1
 [2017-08-28 08:23 UTC]
-Assigned To: +Assigned To: requinix
 [2017-08-28 08:23 UTC]
I can't reproduce.

Please open a new bug report with whatever you have, including build environment if you built PHP yourself.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed May 19 03:01:24 2021 UTC