Skip to content

Commit 7f08019

Browse files
committed
main: drop now unnecessary zend_{try|catch} in user stream open file wrapper
This was initially introduced with 9f86cdaf7fc4 However, this should also have been done for the opendir call. This omission was found via OSS-Fuzz 51047 [1] and fixed in a more general way in d0b3096 by resetting `FG(user_stream_current_filename)` at the end of the request during shutdown. As such this zend_try/zend_catch block is no unnecessary. [1]: https://issues.oss-fuzz.com/issues/42515581
1 parent 2b48e74 commit 7f08019

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

main/streams/userspace.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -321,25 +321,19 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
321321
goto end;
322322
}
323323

324-
/* call it's stream_open method - set up params first */
325-
zend_result call_result;
326-
zend_try {
327-
ZVAL_STRING(&args[0], filename);
328-
ZVAL_STRING(&args[1], mode);
329-
ZVAL_LONG(&args[2], options);
330-
ZVAL_NEW_REF(&args[3], &EG(uninitialized_zval));
331-
332-
zend_string *func_name = ZSTR_INIT_LITERAL(USERSTREAM_OPEN, false);
333-
call_result = zend_call_method_if_exists(Z_OBJ(us->object), func_name, &zretval, 4, args);
334-
zend_string_release_ex(func_name, false);
324+
/* call its stream_open method - set up params first */
325+
ZVAL_STRING(&args[0], filename);
326+
ZVAL_STRING(&args[1], mode);
327+
ZVAL_LONG(&args[2], options);
328+
ZVAL_NEW_REF(&args[3], &EG(uninitialized_zval));
335329

336-
/* Keep arg3 alive if it has assigned the reference */
337-
zval_ptr_dtor(&args[1]);
338-
zval_ptr_dtor(&args[0]);
339-
} zend_catch {
340-
FG(user_stream_current_filename) = NULL;
341-
zend_bailout();
342-
} zend_end_try();
330+
zend_string *func_name = ZSTR_INIT_LITERAL(USERSTREAM_OPEN, false);
331+
zend_result call_result = zend_call_method_if_exists(Z_OBJ(us->object), func_name, &zretval, 4, args);
332+
zend_string_release_ex(func_name, false);
333+
334+
/* Keep arg3 alive if it has assigned the reference */
335+
zval_ptr_dtor(&args[1]);
336+
zval_ptr_dtor(&args[0]);
343337

344338
if (UNEXPECTED(call_result == FAILURE)) {
345339
php_stream_wrapper_log_error(wrapper, options, "\"%s::" USERSTREAM_OPEN "\" is not implemented",

0 commit comments

Comments
 (0)