From: Sara Golemon Date: Wed, 12 Oct 2016 04:14:25 +0000 (-0700) Subject: Clear FG(user_stream_current_filename) when bailing out X-Git-Tag: php-5.6.28RC1~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=43ccf23d700ae780451e257f5a66d4210f82f026;p=php Clear FG(user_stream_current_filename) when bailing out If a userwrapper opener E_ERRORs then FG(user_stream_current_filename) would remain set until the next request and would not be pointing at unallocated memory. Catch the bailout, clear the variable, then continue bailing. Closes https://bugs.php.net/bug.php?id=73188 --- diff --git a/NEWS b/NEWS index cf765ff3dc..d9e6b4c1d3 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ PHP NEWS - Standard: . Fixed bug #73203 (passing additional_parameters causes mail to fail). (cmb) + . Fixed bug #73188 (use after free in userspace streams). (Sara) 13 Oct 2016, PHP 5.6.27 diff --git a/ext/standard/tests/streams/user-stream-error.phpt b/ext/standard/tests/streams/user-stream-error.phpt new file mode 100644 index 0000000000..e7351b4916 --- /dev/null +++ b/ext/standard/tests/streams/user-stream-error.phpt @@ -0,0 +1,16 @@ +--TEST-- +E_ERROR during UserStream Open +--FILE-- +object, - zfuncname, - &zretval, - 4, args, - 0, NULL TSRMLS_CC); + zend_try { + call_result = call_user_function_ex(NULL, + &us->object, + zfuncname, + &zretval, + 4, args, + 0, NULL TSRMLS_CC); + } zend_catch { + FG(user_stream_current_filename) = NULL; + zend_bailout(); + } zend_end_try(); if (call_result == SUCCESS && zretval != NULL && zval_is_true(zretval)) { /* the stream is now open! */