Skip to content

Conversation

nikic
Copy link
Member

@nikic nikic commented Jul 18, 2019

Errors inside stream write operations are currently ignored and will typically result from a 0 return value from fwrite(), contrary to documentation. This can to severe bugs, including denial of service (https://bugs.php.net/bug.php?id=73535).

This PR changes the stream APIs to use a ssize_t return value, where negative returns indicate an error, similar to the write() libc function. This is then propagated through various stream wrappers and using functions. There's probably more places that can check for errors, but this puts the basic scaffolding in place.

Ideally something similar would also be done for read operations.

@nikic nikic added this to the PHP 7.4 milestone Jul 18, 2019
@nikic nikic force-pushed the write-fail branch 3 times, most recently from 6bf6984 to ab6ff04 Compare July 18, 2019 15:36
@nikic
Copy link
Member Author

nikic commented Jul 20, 2019

Closing this in favor of #4442. It's better to handle reads+writes together.

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.

1 participant