Skip to content

ext/standard: Handle file_put_contents() truncation failures - #25034

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/aph-doib
Open

iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/aph-doib

Conversation

@iliaal

@iliaal iliaal commented Oct 29, 2026

Copy link
Copy Markdown
Member

Static review found that file_put_contents() with LOCK_EX reports success after a truncation failure and can leave old file contents behind. It now stops before writing when truncation fails, while preserving writes to native devices such as /dev/null and NUL. Reproduced with a stream wrapper and injected native-file errors on Linux.

Fail locked replacements when truncation fails, before writing data or
consuming the source stream. Preserve writes to native nonregular files,
which may support locking and writing without supporting truncation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant