com php-src: Backported bug #71144 (Segmentation fault when using cURL with ZTS): ext/curl/interface.c ext/curl/tests/bug71144.phpt
| From: | JulienPauli | Date: | Fri, 08 Jul 2016 12:58:56 +0000 |
| Subject: | com php-src: Backported bug #71144 (Segmentation fault when using cURL with ZTS): ext/curl/interface.c ext/curl/tests/bug71144.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92874@lists.php.net to get a copy of this message | ||
Commit: 78d5783b6259889dc97a060be611ba9aca26d87f
Author: Julien Pauli <jpauli@php.net> Fri, 8 Jul 2016 14:58:56 +0200
Parents: 0be13d2dc24f2802a231f92912ba5d089dad6676
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=78d5783b6259889dc97a060be611ba9aca26d87f
Log:
Backported bug #71144 (Segmentation fault when using cURL with ZTS)
Bugs:
https://bugs.php.net/71144
Changed paths:
M ext/curl/interface.c
A ext/curl/tests/bug71144.phpt
Diff:
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 19d8bb0..7e58c7f 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -1925,7 +1925,9 @@ static void _php_curl_set_default_options(php_curl *ch)
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
+#if !defined(ZTS)
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
+#endif
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
@@ -2263,7 +2265,14 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue
TSRMLS_DC)
return 1;
}
#endif
+# if defined(ZTS)
+ if (option == CURLOPT_DNS_USE_GLOBAL_CACHE) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_DNS_USE_GLOBAL_CACHE cannot be
activated when thread safety is enabled");
+ return 1;
+ }
+# endif
error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
+
break;
case CURLOPT_SAFE_UPLOAD:
convert_to_long_ex(zvalue);
diff --git a/ext/curl/tests/bug71144.phpt b/ext/curl/tests/bug71144.phpt
new file mode 100644
index 0000000..059cd63
--- /dev/null
+++ b/ext/curl/tests/bug71144.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #71144 (Sementation fault when using cURL with ZTS)
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+<?php if (!PHP_ZTS) { print "skip only for zts build"; } ?>
+--FILE--
+<?php
+$ch = curl_init();
+var_dump(curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, 1));
+?>
+--EXPECTF--
+Warning: curl_setopt(): CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is
enabled in %sbug71144.php on line %d
+bool(false)