Skip to content

Conversation

alexandre-daubois
Copy link
Member

Fix #19685

When blocks or work have invalid values, it currently let the function execution continue. Instead, we should free some resources and return null to avoid the segfault.

@alexandre-daubois alexandre-daubois changed the base branch from master to PHP-8.3 September 4, 2025 14:42
@alexandre-daubois alexandre-daubois force-pushed the stream-append-bz2-failure branch from e6d35d8 to 4c88e07 Compare September 4, 2025 15:01
@alexandre-daubois alexandre-daubois marked this pull request as ready for review September 4, 2025 15:24
@@ -367,6 +367,10 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi
zend_long blocks = zval_get_long(tmpzval);
if (blocks < 1 || blocks > 9) {
php_error_docref(NULL, E_WARNING, "Invalid parameter given for number of blocks to allocate (" ZEND_LONG_FMT ")", blocks);
pefree(data->strm.next_in, persistent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: only if you want, on master only maybe, making a goto label to cover the 3 cases.

@bukka
Copy link
Member

bukka commented Sep 4, 2025

It should be ok in this case but breaking filter chain is sometimes not safe (might cause breaks) so I will need to review it properly - I should be properly looking to filters in 2 or 3 weeks time.

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.

segmentation fault
4 participants