From: Julien Pauli Date: Fri, 8 Jul 2016 12:58:56 +0000 (+0200) Subject: Backported bug #71144 (Segmentation fault when using cURL with ZTS) X-Git-Tag: php-7.1.0beta1~147^2~1^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=78d5783b6259889dc97a060be611ba9aca26d87f;p=php Backported bug #71144 (Segmentation fault when using cURL with ZTS) --- diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 19d8bb02b5..7e58c7f1e0 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 0000000000..059cd63651 --- /dev/null +++ b/ext/curl/tests/bug71144.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #71144 (Sementation fault when using cURL with ZTS) +--SKIPIF-- + + +--FILE-- + +--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)