diff options
author | Pedro Magalhães <pmmaga@php.net> | 2019-01-16 00:33:03 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-18 12:04:25 +0100 |
commit | 32ae7160377e9548dcf27ff3e0e75c3c9cd3c36c (patch) | |
tree | 4fb3b2fc6160c79f518f02dff1f5b92562f81562 /ext/curl | |
parent | 61cfa34e1194b5a026548508f9f34d6f6a8774da (diff) | |
download | php-git-32ae7160377e9548dcf27ff3e0e75c3c9cd3c36c.tar.gz |
Fixed bug #76675
Leave a reference to the resource in the php_curl.
Diffstat (limited to 'ext/curl')
-rw-r--r-- | ext/curl/multi.c | 1 | ||||
-rw-r--r-- | ext/curl/tests/bug76675.phpt | 53 |
2 files changed, 54 insertions, 0 deletions
diff --git a/ext/curl/multi.c b/ext/curl/multi.c index 3afe8ac413..073a6b3688 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -509,6 +509,7 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea Z_ADDREF_P(pz_parent_ch); res = zend_register_resource(ch, le_curl); + ch->res = res; ZVAL_RES(&pz_ch, res); size_t i; diff --git a/ext/curl/tests/bug76675.phpt b/ext/curl/tests/bug76675.phpt new file mode 100644 index 0000000000..5e60c5c47f --- /dev/null +++ b/ext/curl/tests/bug76675.phpt @@ -0,0 +1,53 @@ +--TEST-- +Bug #76675 (Segfault with H2 server push write/writeheader handlers) +--SKIPIF-- +<?php +include 'skipif.inc'; +if (getenv("SKIP_ONLINE_TESTS")) { + die("skip online test"); +} +$curl_version = curl_version(); +if ($curl_version['version_number'] < 0x073d00) { + exit("skip: test may crash with curl < 7.61.0"); +} +?> +--FILE-- +<?php +$transfers = 1; +$callback = function($parent, $passed) use (&$transfers) { + curl_setopt($passed, CURLOPT_WRITEFUNCTION, function ($ch, $data) { + echo "Received ".strlen($data); + return strlen($data); + }); + $transfers++; + return CURL_PUSH_OK; +}; +$mh = curl_multi_init(); +curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX); +curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback); +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, 'https://http2.golang.org/serverpush'); +curl_setopt($ch, CURLOPT_HTTP_VERSION, 3); +curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); +curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); +curl_multi_add_handle($mh, $ch); +$active = null; +do { + $status = curl_multi_exec($mh, $active); + do { + $info = curl_multi_info_read($mh); + if (false !== $info && $info['msg'] == CURLMSG_DONE) { + $handle = $info['handle']; + if ($handle !== null) { + $transfers--; + curl_multi_remove_handle($mh, $handle); + curl_close($handle); + } + } + } while ($info); +} while ($transfers); +curl_multi_close($mh); +?> +--EXPECTREGEX-- +(Received \d+)+ |