summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2016-02-05 19:49:26 +0800
committerXinchen Hui <laruence@gmail.com>2016-02-05 19:49:26 +0800
commit5fdfab743d964bb13602effc9efcd6f747e2f58c (patch)
tree270083f136799e4b51578e7e136b43265f68688b
parent8442a1cc4ee79b09b5bb21d64aa87edcea453c21 (diff)
downloadphp-git-5fdfab743d964bb13602effc9efcd6f747e2f58c.tar.gz
Fixed bug #71523 (Copied handle with new option CURLOPT_HTTPHEADER crashes while curl_multi_exec)
-rw-r--r--NEWS4
-rw-r--r--ext/curl/interface.c7
-rw-r--r--ext/curl/tests/bug71523.phpt28
3 files changed, 38 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index f3ebebae4d..0fc0565798 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2016, PHP 5.6.19
+- CURL:
+ . Fixed bug #71523 (Copied handle with new option CURLOPT_HTTPHEADER crashes
+ while curl_multi_exec). (Laruence)
+
- Date:
. Fixed bug #68078 (Datetime comparisons ignore microseconds). (Willem-Jan
Zijderveld)
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 267afecd8b..d9aab7541c 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -2543,7 +2543,12 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue TSRMLS_DC)
return 1;
}
}
- zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NULL);
+
+ if (Z_REFCOUNT_P(ch->clone) <= 1) {
+ zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NULL);
+ } else {
+ zend_hash_next_index_insert(ch->to_free->slist, &slist, sizeof(struct curl_slist *), NULL);
+ }
error = curl_easy_setopt(ch->cp, option, slist);
diff --git a/ext/curl/tests/bug71523.phpt b/ext/curl/tests/bug71523.phpt
new file mode 100644
index 0000000000..06647de12d
--- /dev/null
+++ b/ext/curl/tests/bug71523.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #71523 (Copied handle with new option CURLOPT_HTTPHEADER crashes while curl_multi_exec)
+--SKIPIF--
+<?php
+if (!extension_loaded("curl")) {
+ exit("skip curl extension not loaded");
+}
+?>
+--FILE--
+<?php
+
+$base = curl_init('http://www.google.com/');
+curl_setopt($base, CURLOPT_RETURNTRANSFER, true);
+$mh = curl_multi_init();
+
+for ($i = 0; $i < 2; ++$i) {
+ $ch = curl_copy_handle($base);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, ['Foo: Bar']);
+ curl_multi_add_handle($mh, $ch);
+}
+
+do {
+ curl_multi_exec($mh, $active);
+} while ($active);
+?>
+okey
+--EXPECTF--
+okey