Skip to content

Comments

[12.x] Fix Filesystem::sharedGet partial reads (#58418)#58419

Merged
taylorotwell merged 1 commit intolaravel:12.xfrom
sv63rus:fix/58418-filesystem-sharedget-partial-read
Jan 19, 2026
Merged

[12.x] Fix Filesystem::sharedGet partial reads (#58418)#58419
taylorotwell merged 1 commit intolaravel:12.xfrom
sv63rus:fix/58418-filesystem-sharedget-partial-read

Conversation

@sv63rus
Copy link
Contributor

@sv63rus sv63rus commented Jan 18, 2026

Filesystem::sharedGet relied on a single fread() call to read the entire file.

Since fread() may return fewer bytes than requested, this could result in truncated reads (often 8 KiB) even when the underlying file or stream contains more data.

This change replaces the single fread() call with stream_get_contents() to ensure the entire stream is read, and adds a regression test using a custom stream wrapper that simulates partial reads.

Fixes #58418

Filesystem::sharedGet relied on a single fread() call to read the entire file.

Since fread() may return fewer bytes than requested, this could result in
truncated reads (often 8 KiB) even when the underlying file or stream
contains more data.

This change replaces the single fread() call with stream_get_contents()
to ensure the entire stream is read, and adds a regression test using a
custom stream wrapper that simulates partial reads.

Fixes laravel#58418
@sv63rus sv63rus force-pushed the fix/58418-filesystem-sharedget-partial-read branch from 7ed7909 to e666280 Compare January 18, 2026 13:25
@sv63rus sv63rus changed the title Fix Filesystem::sharedGet partial reads (#58418) [12.x] Fix Filesystem::sharedGet partial reads (#58418) Jan 18, 2026
@taylorotwell taylorotwell merged commit eceedba into laravel:12.x Jan 19, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filesystem::sharedGet may return only 8 KiB due to single fread() call

2 participants