From 58be64ce2b152c9c0cb631f96a918d5469c59f0f Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Wed, 7 May 2008 20:02:42 +0000 Subject: [PATCH] MFH: Fixed bug #44712 (stream_context_set_params segfaults on invalid arguments). --- ext/standard/streamsfuncs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index ca598a7f2b..60560314ee 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -879,7 +879,7 @@ static int parse_context_options(php_stream_context *context, zval *options) return ret; } -static int parse_context_params(php_stream_context *context, zval *params) +static int parse_context_params(php_stream_context *context, zval *params TSRMLS_DC) { int ret = SUCCESS; zval **tmp; @@ -898,7 +898,11 @@ static int parse_context_params(php_stream_context *context, zval *params) context->notifier->dtor = user_space_stream_notifier_dtor; } if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) { - parse_context_options(context, *tmp); + if (Z_TYPE_PP(tmp) == IS_ARRAY) { + parse_context_options(context, *tmp); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter"); + } } return ret; @@ -1006,7 +1010,7 @@ PHP_FUNCTION(stream_context_set_params) RETURN_FALSE; } - RETVAL_BOOL(parse_context_params(context, params) == SUCCESS); + RETVAL_BOOL(parse_context_params(context, params TSRMLS_CC) == SUCCESS); } /* }}} */ -- 2.50.1