-
-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Version: 2.4.1
Ubuntu 20.04.2 LTS
PHP 8.0.5
Bug Description
fopen('safe://' . 'some_file_path', 'a');
results in:
stream_copy_to_stream(): Read of 8192 bytes failed with errno=9 Bad file descriptor
Expected Behavior
fopen('safe://' . some_file_path, 'a');
opens the file
file didn't exist on the given path, so it should be created
Possible Solution
SafeStream.php:114
if (stream_copy_to_stream($this->handle, $this->tempHandle) !== $stat['size']) {
tries to read from file $this->handle opend with readonly mode 'x'
this looks like proper behavior of PHP - not a bug in PHP:
https://bugs.php.net/bug.php?id=78482
if the file would be open with flag 'x+', everything works just fine:
SafeStream.php:89
if ($this->checkAndLock($this->handle = @fopen($path, 'x' . $flag, $use_path), LOCK_EX)) {
if $flag would be '+' -- works fine, but $flag is empty string ''