Bug #46673 [Csd]: stream_lock call with wrong paramater

From: Date: Mon, 28 Aug 2017 08:23:39 +0000
Subject: Bug #46673 [Csd]: stream_lock call with wrong paramater
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210845@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=46673&edit=1

 ID:                 46673
 Updated by:         requinix@php.net
 Reported by:        kaz at e-2 dot co dot jp
 Summary:            stream_lock call with wrong paramater
 Status:             Closed
 Type:               Bug
 Package:            Streams related
 Operating System:   *
 PHP Version:        5.2.6
-Assigned To:        
+Assigned To:        requinix
 Block user comment: N
 Private report:     N

 New Comment:

I can't reproduce. https://3v4l.org/7HCA8

Please open a new bug report with whatever you have, including build environment if you built PHP
yourself. https://bugs.php.net/report.php


Previous Comments:
------------------------------------------------------------------------
[2017-08-28 08:16:38] adolph dot bauer2 at gmail dot com

I found this bug to be reproducable in PHP version 7.1

------------------------------------------------------------------------
[2014-08-16 15:38:44] 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.

------------------------------------------------------------------------
[2008-11-26 04:20:50] lbarnaud@php.net

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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.



------------------------------------------------------------------------
[2008-11-26 03:07:51] kaz at e-2 dot co dot jp

Description:
------------
When i regist my own stream class, and use flock($h, LOCK_UN).
then steam_lock caled with undefined mode(0x8).

php-5.2.6/ext/standard/file.c
----
321 static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN };
snip...
348 act = flock_values[act - 1] | (operation & 4 ? LOCK_NB : 0);
349 if (php_stream_lock(stream, act)) {


Reproduce code:
---------------
<?php
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:
----------------
0x2
0x3


Actual result:
--------------
0x2
0x8



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=46673&edit=1


Thread (5 messages)

« previous php.bugs (#210845) next »