Skip to content

Commit e787d6c

Browse files
authored
Fix GH-10548: copy() fails on cifs mounts because of incorrect length (cfr_max) specified in streams.c:1584 copy_file_range() (#10551)
On some filesystems, the copy operation fails if we specify a size larger than the file size in certain circumstances and configurations. In those cases EIO will be returned as errno and we will therefore fall back to other methods.
1 parent 0d56a5b commit e787d6c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

main/streams/streams.c

+7
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,13 @@ PHPAPI zend_result _php_stream_copy_to_stream_ex(php_stream *src, php_stream *de
16141614
/* not implemented by this Linux kernel */
16151615
break;
16161616

1617+
case EIO:
1618+
/* Some filesystems will cause failures if the max length is greater than the file length
1619+
* in certain circumstances and configuration. In those cases the errno is EIO and we will
1620+
* fall back to other methods. We cannot use stat to determine the file length upfront because
1621+
* that is prone to races and outdated caching. */
1622+
break;
1623+
16171624
default:
16181625
/* unexpected I/O error - give up, no fallback */
16191626
*len = haveread;

0 commit comments

Comments
 (0)