summaryrefslogtreecommitdiff
path: root/ext/curl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/curl')
-rw-r--r--ext/curl/interface.c34
-rw-r--r--ext/curl/php_curl.h4
-rw-r--r--ext/curl/tests/bug52202.phpt16
-rw-r--r--ext/curl/tests/bug52827.phpt32
-rw-r--r--ext/curl/tests/curl_multi_getcontent_basic3.phpt7
-rw-r--r--ext/curl/tests/curl_multi_getcontent_error1.phpt4
-rw-r--r--ext/curl/tests/curl_multi_getcontent_error2.phpt4
-rw-r--r--ext/curl/tests/curl_multi_getcontent_error3.phpt4
-rw-r--r--ext/curl/tests/curl_multi_getcontent_error4.phpt4
-rw-r--r--ext/curl/tests/curl_setopt_basic001.phpt2
-rw-r--r--ext/curl/tests/curl_setopt_error.phpt1
11 files changed, 82 insertions, 30 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 35cc1d996..610861eb5 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: interface.c 298299 2010-04-22 08:58:07Z pajoye $ */
+/* $Id: interface.c 305850 2010-11-30 13:40:02Z iliaa $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
@@ -1252,7 +1252,6 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
/* }}} */
#endif
-#if LIBCURL_VERSION_NUM < 0x071101
/* {{{ curl_free_string
*/
static void curl_free_string(void **string)
@@ -1260,7 +1259,6 @@ static void curl_free_string(void **string)
efree(*string);
}
/* }}} */
-#endif
/* {{{ curl_free_post
*/
@@ -1337,9 +1335,7 @@ static void alloc_curl_handle(php_curl **ch)
memset(&(*ch)->err, 0, sizeof((*ch)->err));
-#if LIBCURL_VERSION_NUM < 0x071101
zend_llist_init(&(*ch)->to_free.str, sizeof(char *), (llist_dtor_func_t) curl_free_string, 0);
-#endif
zend_llist_init(&(*ch)->to_free.slist, sizeof(struct curl_slist), (llist_dtor_func_t) curl_free_slist, 0);
zend_llist_init(&(*ch)->to_free.post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_post, 0);
}
@@ -1556,11 +1552,10 @@ PHP_FUNCTION(curl_copy_handle)
curl_easy_setopt(dupch->cp, CURLOPT_INFILE, (void *) dupch);
curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch);
-#if LIBCURL_VERSION_NUM < 0x071101
zend_llist_copy(&dupch->to_free.str, &ch->to_free.str);
/* Don't try to free copied strings, they're free'd when the original handle is destroyed */
dupch->to_free.str.dtor = NULL;
-#endif
+
zend_llist_copy(&dupch->to_free.slist, &ch->to_free.slist);
zend_llist_copy(&dupch->to_free.post, &ch->to_free.post);
@@ -1742,14 +1737,22 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
return 1;
}
} else {
+ if (option == CURLOPT_PRIVATE) {
+ char *copystr;
+#if LIBCURL_VERSION_NUM < 0x071100
+string_copy:
+#endif
+ copystr = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue));
+ error = curl_easy_setopt(ch->cp, option, copystr);
+ zend_llist_add_element(&ch->to_free.str, &copystr);
+ } else {
#if LIBCURL_VERSION_NUM >= 0x071100
- /* Strings passed to libcurl as ’char *’ arguments, are copied by the library... NOTE: before 7.17.0 strings were not copied. */
- error = curl_easy_setopt(ch->cp, option, Z_STRVAL_PP(zvalue));
-#else
- copystr = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue));
- error = curl_easy_setopt(ch->cp, option, copystr);
- zend_llist_add_element(&ch->to_free.str, &copystr);
+ /* Strings passed to libcurl as ’char *’ arguments, are copied by the library... NOTE: before 7.17.0 strings were not copied. */
+ error = curl_easy_setopt(ch->cp, option, Z_STRVAL_PP(zvalue));
+#else
+ goto string_copy;
#endif
+ }
}
break;
}
@@ -1761,7 +1764,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
int type;
void * what;
- what = zend_fetch_resource(zvalue TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream());
+ what = zend_fetch_resource(zvalue TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream(), php_file_le_pstream());
if (!what) {
RETVAL_FALSE;
return 1;
@@ -1816,7 +1819,6 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
}
zval_add_ref(zvalue);
ch->handlers->std_err = *zvalue;
- zend_list_addref(Z_LVAL_PP(zvalue));
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable");
RETVAL_FALSE;
@@ -2457,9 +2459,7 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
}
curl_easy_cleanup(ch->cp);
-#if LIBCURL_VERSION_NUM < 0x071101
zend_llist_clean(&ch->to_free.str);
-#endif
/* cURL destructors should be invoked only by last curl handle */
if (Z_REFCOUNT_P(ch->clone) <= 1) {
diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h
index 21e3ec1d2..a525cc6eb 100644
--- a/ext/curl/php_curl.h
+++ b/ext/curl/php_curl.h
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_curl.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_curl.h 305854 2010-11-30 16:11:27Z iliaa $ */
#ifndef _PHP_CURL_H
#define _PHP_CURL_H
@@ -124,9 +124,7 @@ struct _php_curl_send_headers {
};
struct _php_curl_free {
-#if LIBCURL_VERSION_NUM < 0x071100
zend_llist str;
-#endif
zend_llist post;
zend_llist slist;
};
diff --git a/ext/curl/tests/bug52202.phpt b/ext/curl/tests/bug52202.phpt
new file mode 100644
index 000000000..a304d7f77
--- /dev/null
+++ b/ext/curl/tests/bug52202.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #52202 (CURLOPT_PRIVATE gets clobbered)
+--SKIPIF--
+<?php
+if (!extension_loaded('curl')) exit("skip curl extension not loaded");
+?>
+--FILE--
+<?php
+$curl = curl_init("http://www.google.com");
+curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($curl, CURLOPT_PRIVATE, "123");
+curl_exec($curl);
+
+var_dump(curl_getinfo($curl, CURLINFO_PRIVATE));
+--EXPECT--
+string(3) "123"
diff --git a/ext/curl/tests/bug52827.phpt b/ext/curl/tests/bug52827.phpt
new file mode 100644
index 000000000..85a73fa79
--- /dev/null
+++ b/ext/curl/tests/bug52827.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #52827 (curl_setopt with CURLOPT_STDERR erroneously increments the resource refcount)
+--SKIPIF--
+<?php
+
+if (!extension_loaded('curl')) {
+ exit("skip curl extension not loaded");
+}
+
+?>
+--FILE--
+<?php
+$s = fopen('php://temp/maxmemory=1024','wb+');
+
+/* force conversion of inner stream to STDIO.
+ * This is not necessary in Windows because the
+ * cast to a FILE* handle in curl_setopt already
+ * forces the conversion in that platform. The
+ * reason for this conversion is that the memory
+ * stream has an ugly but working mechanism to
+ * prevent being double freed when it's encapsulated,
+ * while STDIO streams don't. */
+$i = 0;
+while ($i++ < 5000) {
+fwrite($s, str_repeat('a',1024));
+}
+$handle=curl_init('http://www.example.com');
+curl_setopt($handle, CURLOPT_STDERR, $s);
+
+echo "Done.";
+--EXPECTF--
+Done.
diff --git a/ext/curl/tests/curl_multi_getcontent_basic3.phpt b/ext/curl/tests/curl_multi_getcontent_basic3.phpt
index 1434c58d0..bf17ab6b6 100644
--- a/ext/curl/tests/curl_multi_getcontent_basic3.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_basic3.phpt
@@ -17,7 +17,7 @@ if (!extension_loaded('curl')) print 'skip';
//SET URL AND OTHER OPTIONS
curl_setopt($ch1, CURLOPT_URL, "http://php.net/robots.txt");
- curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+ curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
@@ -55,5 +55,10 @@ Disallow: /source.php
Disallow: /search.php
Disallow: /mod.php
Disallow: /manual/add-note.php
+
+Disallow: /harming/humans
+Disallow: /ignoring/human/orders
+Disallow: /harm/to/self
+
CURL2
diff --git a/ext/curl/tests/curl_multi_getcontent_error1.phpt b/ext/curl/tests/curl_multi_getcontent_error1.phpt
index 88de0d7d3..2fb11b3d9 100644
--- a/ext/curl/tests/curl_multi_getcontent_error1.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_error1.phpt
@@ -16,8 +16,8 @@ if (!extension_loaded('curl')) print 'skip';
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
- curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata1.txt");
- curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+ curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
+ curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
diff --git a/ext/curl/tests/curl_multi_getcontent_error2.phpt b/ext/curl/tests/curl_multi_getcontent_error2.phpt
index ad837d828..0145d6a8f 100644
--- a/ext/curl/tests/curl_multi_getcontent_error2.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_error2.phpt
@@ -16,8 +16,8 @@ if (!extension_loaded('curl')) print 'skip';
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
- curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata1.txt");
- curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+ curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
+ curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
diff --git a/ext/curl/tests/curl_multi_getcontent_error3.phpt b/ext/curl/tests/curl_multi_getcontent_error3.phpt
index 6ffc6b736..2ad14804b 100644
--- a/ext/curl/tests/curl_multi_getcontent_error3.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_error3.phpt
@@ -16,8 +16,8 @@ if (!extension_loaded('curl')) print 'skip';
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
- curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata1.txt");
- curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+ curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
+ curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
diff --git a/ext/curl/tests/curl_multi_getcontent_error4.phpt b/ext/curl/tests/curl_multi_getcontent_error4.phpt
index 68928647a..68bda37fe 100644
--- a/ext/curl/tests/curl_multi_getcontent_error4.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_error4.phpt
@@ -16,8 +16,8 @@ if (!extension_loaded('curl')) print 'skip';
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
- curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata1.txt");
- curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+ curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
+ curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
diff --git a/ext/curl/tests/curl_setopt_basic001.phpt b/ext/curl/tests/curl_setopt_basic001.phpt
index 178fbf7c1..9c92785b0 100644
--- a/ext/curl/tests/curl_setopt_basic001.phpt
+++ b/ext/curl/tests/curl_setopt_basic001.phpt
@@ -27,7 +27,7 @@ curl_close($ch);
var_dump( $curl_content );
?>
--EXPECTF--
-Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
*** Testing curl_setopt with CURLOPT_FOLLOWLOCATION in safemode
Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in %s on line %d
diff --git a/ext/curl/tests/curl_setopt_error.phpt b/ext/curl/tests/curl_setopt_error.phpt
index 5489b34e2..ad73318f1 100644
--- a/ext/curl/tests/curl_setopt_error.phpt
+++ b/ext/curl/tests/curl_setopt_error.phpt
@@ -42,3 +42,4 @@ Warning: curl_setopt() expects parameter 1 to be resource, boolean given in %s o
Warning: curl_setopt() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
+Warning: curl_setopt(): Invalid curl configuration option in %scurl_setopt_error.php on line %d