summaryrefslogtreecommitdiff
path: root/ext/curl/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/curl/interface.c')
-rw-r--r--ext/curl/interface.c85
1 files changed, 61 insertions, 24 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 02f7fdf76..8afdf944e 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -10,7 +10,7 @@
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
+ | license@php.net so we can mail you 6 copy immediately. |
+----------------------------------------------------------------------+
| Author: Sterling Hughes <sterling@php.net> |
+----------------------------------------------------------------------+
@@ -164,16 +164,14 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC);
# define php_curl_ret(__ret) RETVAL_FALSE; return;
#endif
-static int php_curl_option_url(php_curl *ch, const char *url, const int len) /* {{{ */
+static int php_curl_option_url(php_curl *ch, const char *url, const int len TSRMLS_DC) /* {{{ */
{
CURLcode error = CURLE_OK;
#if LIBCURL_VERSION_NUM < 0x071100
char *copystr = NULL;
#endif
- TSRMLS_FETCH();
-
- /* Disable file:// if open_basedir or safe_mode are used */
- if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) {
+ /* Disable file:// if open_basedir are used */
+ if (PG(open_basedir) && *PG(open_basedir)) {
#if LIBCURL_VERSION_NUM >= 0x071304
error = curl_easy_setopt(ch->cp, CURLOPT_PROTOCOLS, CURLPROTO_ALL & ~CURLPROTO_FILE);
#else
@@ -1547,8 +1545,6 @@ PHP_FUNCTION(curl_init)
MAKE_STD_ZVAL(clone);
ch->clone = clone;
-
-
curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
@@ -1572,7 +1568,7 @@ PHP_FUNCTION(curl_init)
#endif
if (url) {
- if (!php_curl_option_url(ch, url, url_len)) {
+ if (!php_curl_option_url(ch, url, url_len TSRMLS_CC)) {
_php_curl_close_ex(ch TSRMLS_CC);
RETURN_FALSE;
}
@@ -1767,8 +1763,8 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
convert_to_long_ex(zvalue);
#if LIBCURL_VERSION_NUM >= 0x71304
if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) &&
- ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) && (Z_LVAL_PP(zvalue) & CURLPROTO_FILE)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLPROTO_FILE cannot be activated when in safe_mode or an open_basedir is set");
+ (PG(open_basedir) && *PG(open_basedir)) && (Z_LVAL_PP(zvalue) & CURLPROTO_FILE)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLPROTO_FILE cannot be activated when an open_basedir is set");
RETVAL_FALSE;
return 1;
}
@@ -1784,9 +1780,9 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
#endif
case CURLOPT_FOLLOWLOCATION:
convert_to_long_ex(zvalue);
- if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) {
+ if (PG(open_basedir) && *PG(open_basedir)) {
if (Z_LVAL_PP(zvalue) != 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set");
RETVAL_FALSE;
return 1;
}
@@ -1838,14 +1834,14 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
option == CURLOPT_SSH_PUBLIC_KEYFILE || option == CURLOPT_SSH_PRIVATE_KEYFILE
) {
- if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(zvalue), "rb+", CHECKUID_CHECK_MODE_PARAM))) {
+ if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) {
RETVAL_FALSE;
return 1;
}
}
#endif
if (option == CURLOPT_URL) {
- if (!php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue))) {
+ if (!php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue) TSRMLS_CC)) {
RETVAL_FALSE;
return 1;
}
@@ -2027,10 +2023,6 @@ string_copy:
HashTable *postfields;
struct HttpPost *first = NULL;
struct HttpPost *last = NULL;
- char *postval;
- char *string_key = NULL;
- ulong num_key;
- uint string_key_len;
postfields = HASH_OF(*zvalue);
if (!postfields) {
@@ -2043,12 +2035,26 @@ string_copy:
zend_hash_get_current_data(postfields, (void **) &current) == SUCCESS;
zend_hash_move_forward(postfields)
) {
+ char *postval;
+ char *string_key = NULL;
+ uint string_key_len;
+ ulong num_key;
+ int numeric_key;
SEPARATE_ZVAL(current);
convert_to_string_ex(current);
zend_hash_get_current_key_ex(postfields, &string_key, &string_key_len, &num_key, 0, NULL);
+ /* Pretend we have a string_key here */
+ if(!string_key) {
+ spprintf(&string_key, 0, "%ld", num_key);
+ string_key_len = strlen(string_key)+1;
+ numeric_key = 1;
+ } else {
+ numeric_key = 0;
+ }
+
postval = Z_STRVAL_PP(current);
/* The arguments after _NAMELENGTH and _CONTENTSLENGTH
@@ -2064,8 +2070,8 @@ string_copy:
if ((filename = php_memnstr(postval, ";filename=", sizeof(";filename=") - 1, postval + Z_STRLEN_PP(current)))) {
*filename = '\0';
}
- /* safe_mode / open_basedir check */
- if (php_check_open_basedir(postval TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(postval, "rb+", CHECKUID_CHECK_MODE_PARAM))) {
+ /* open_basedir check */
+ if (php_check_open_basedir(postval TSRMLS_CC)) {
RETVAL_FALSE;
return 1;
}
@@ -2090,6 +2096,10 @@ string_copy:
CURLFORM_CONTENTSLENGTH, (long)Z_STRLEN_PP(current),
CURLFORM_END);
}
+
+ if (numeric_key) {
+ efree(string_key);
+ }
}
SAVE_CURL_ERROR(ch, error);
@@ -2154,8 +2164,8 @@ string_copy:
break;
}
- /* the following options deal with files, therefor safe_mode & open_basedir checks
- * are required.
+ /* the following options deal with files, therefore the open_basedir check
+ * is required.
*/
case CURLOPT_COOKIEJAR:
case CURLOPT_SSLCERT:
@@ -2167,7 +2177,7 @@ string_copy:
convert_to_string_ex(zvalue);
- if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(zvalue), "rb+", CHECKUID_CHECK_MODE_PARAM))) {
+ if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) {
RETVAL_FALSE;
return 1;
}
@@ -2437,6 +2447,20 @@ PHP_FUNCTION(curl_getinfo)
create_certinfo(ci, listcode TSRMLS_CC);
CAAZ("certinfo", listcode);
}
+ if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) {
+ CAAS("primary_ip", s_code);
+ }
+#endif
+#if LIBCURL_VERSION_NUM > 0x071500
+ if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_PORT, &l_code) == CURLE_OK) {
+ CAAL("primary_port", l_code);
+ }
+ if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_IP, &s_code) == CURLE_OK) {
+ CAAS("local_ip", s_code);
+ }
+ if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_PORT, &l_code) == CURLE_OK) {
+ CAAL("local_port", l_code);
+ }
#endif
#if LIBCURL_VERSION_NUM >= 0x071202
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) {
@@ -2448,6 +2472,13 @@ PHP_FUNCTION(curl_getinfo)
}
} else {
switch (option) {
+ /* string variable types */
+#if LIBCURL_VERSION_NUM >= 0x071500
+ case CURLINFO_PRIMARY_IP:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071500
+ case CURLINFO_LOCAL_IP:
+#endif
case CURLINFO_PRIVATE:
case CURLINFO_EFFECTIVE_URL:
case CURLINFO_CONTENT_TYPE:
@@ -2464,6 +2495,11 @@ PHP_FUNCTION(curl_getinfo)
}
break;
}
+ /* Long variable types */
+#if LIBCURL_VERSION_NUM >= 0x071500
+ case CURLINFO_PRIMARY_PORT:
+ case CURLINFO_LOCAL_PORT:
+#endif
case CURLINFO_HTTP_CODE:
case CURLINFO_HEADER_SIZE:
case CURLINFO_REQUEST_SIZE:
@@ -2479,6 +2515,7 @@ PHP_FUNCTION(curl_getinfo)
}
break;
}
+ /* Double variable types */
case CURLINFO_TOTAL_TIME:
case CURLINFO_NAMELOOKUP_TIME:
case CURLINFO_CONNECT_TIME: