com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: ext/curl/ interface.c ext/curl/php_curl.h
ext/mysqli/mysqli.c ext/mysqli/mysqli_api.c ext/mysqli/php_mysqli_stru cts.h ext/openssl/openssl.c ext/standard/mail.c ext /standard/string.c
ext/standard/tests/strings/substr_comp are.phpt

From: Date: Fri, 28 Feb 2014 18:18:18 +0000
Subject: com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: ext/curl/ interface.c ext/curl/php_curl.h
ext/mysqli/mysqli.c ext/mysqli/mysqli_api.c ext/mysqli/php_mysqli_stru cts.h ext/openssl/openssl.c ext/standard/mail.c ext /standard/string.c
ext/standard/tests/strings/substr_comp are.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-76286@lists.php.net to get a copy of this message
Commit: 28dbadeb1df3072e67375e2d01fdee6b60201408 Author: Anatol Belski <ab@php.net> Fri, 28 Feb 2014 19:18:18 +0100 Parents: 2d83dca7beb5060a30cfde124e5c97d35285990a e424049840394a01bb521c54a98897f87b557dbd Branches: str_size_and_int64_56_backport Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=28dbadeb1df3072e67375e2d01fdee6b60201408 Log: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport * origin/PHP-5.6: (28 commits) substr_compare(): Allow zero length comparison Fixed test case title [bug 66535] X-PHP-Originating-Script adds newline if no custom headers are given Fixed expected output of a few cURL test cases Allow NULL as value for CURLOPT_CUSTOMREQUEST option. primitive test fixes man page: long option name is --strip, not --stripped --global have be removed in 5.2 remove pcntl leftover from the test code list the fpm change hat rfc in UPGRADING mention the apparmor support in fpm typo spotted by Lajos Veres update libs_version.txt update libs_version.txt NEWS NEWS NEWS test for bug #66762 Fixed Bug #66762 Segfault in mysqli_stmt::bind_result() when link closed fix tests broken by 633f898f1520253d3530fe91fc82f68bca7c4627 ... Conflicts: ext/curl/interface.c ext/standard/mail.c ext/standard/string.c Bugs: https://bugs.php.net/66535 https://bugs.php.net/66762 Changed paths: MM ext/curl/interface.c MM ext/curl/php_curl.h MM ext/mysqli/mysqli.c MM ext/mysqli/mysqli_api.c MM ext/mysqli/php_mysqli_structs.h MM ext/openssl/openssl.c MM ext/standard/mail.c MM ext/standard/string.c MM ext/standard/tests/strings/substr_compare..phpt

diff --cc ext/curl/interface.c index 9b01a25,b4fac4b..65d4cf5 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@@ -165,12 -165,28 +165,28 @@@ static void _php_curl_close(zend_rsrc_l # define php_curl_ret(__ret) RETVAL_FALSE; return; #endif - static int php_curl_option_url(php_curl *ch, const char *url, const php_size_t len TSRMLS_DC) /* {{{ */ -static int php_curl_option_str(php_curl *ch, long option, const char *str, const int len, zend_bool make_copy TSRMLS_DC) ++static int php_curl_option_str(php_curl *ch, php_int_t option, const char *str, const php_size_t len, zend_bool make_copy TSRMLS_DC) { CURLcode error = CURLE_OK; - #if LIBCURL_VERSION_NUM < 0x071100 - char *copystr = NULL; - #endif + + if (make_copy || LIBCURL_VERSION_NUM < 0x071100) { + char *copystr; + + /* Strings passed to libcurl as 'char *' arguments, are copied by the library since 7.17.0 */ + copystr = estrndup(str, len); + error = curl_easy_setopt(ch->cp, option, copystr); + zend_llist_add_element(&ch->to_free->str, &copystr); + } else { + error = curl_easy_setopt(ch->cp, option, str); + } + + SAVE_CURL_ERROR(ch, error) + + return error == CURLE_OK ? SUCCESS : FAILURE; + } + + static int php_curl_option_url(php_curl *ch, const char *url, const int len TSRMLS_DC) /* {{{ */ + { /* Disable file:// if open_basedir are used */ if (PG(open_basedir) && *PG(open_basedir)) { #if LIBCURL_VERSION_NUM >= 0x071304 @@@ -2061,7 -2061,7 +2061,7 @@@ PHP_FUNCTION(curl_copy_handle } /* }}} */ - static int _php_curl_setopt(php_curl *ch, php_int_t option, zval **zvalue, zval *return_value TSRMLS_DC) /* {{{ */ -static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue TSRMLS_DC) /* {{{ */ ++static int _php_curl_setopt(php_curl *ch, php_int_t option, zval **zvalue TSRMLS_DC) /* {{{ */ { CURLcode error=CURLE_OK; @@@ -2223,12 -2222,11 +2222,11 @@@ #if CURLOPT_MUTE != 0 case CURLOPT_MUTE: #endif - convert_to_long_ex(zvalue); + convert_to_int_ex(zvalue); #if LIBCURL_VERSION_NUM >= 0x71304 if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) && - (PG(open_basedir) && *PG(open_basedir)) && (Z_LVAL_PP(zvalue) & CURLPROTO_FILE)) { + (PG(open_basedir) && *PG(open_basedir)) && (Z_IVAL_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; } #endif @@@ -2312,32 -2296,44 +2296,44 @@@ #endif { convert_to_string_ex(zvalue); - if (option == CURLOPT_URL) { - if (!php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRSIZE_PP(zvalue) TSRMLS_CC)) { - RETVAL_FALSE; - return 1; - } - } else { - if (option == CURLOPT_PRIVATE) { - char *copystr; - #if LIBCURL_VERSION_NUM < 0x071100 - string_copy: - #endif - copystr = estrndup(Z_STRVAL_PP(zvalue), Z_STRSIZE_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)); - return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue), 0 TSRMLS_CC); ++ return php_curl_option_str(ch, option, Z_STRSIZE_PP(zvalue), Z_STRSIZE_PP(zvalue), 0 TSRMLS_CC); + } + + /* Curl nullable string options */ + case CURLOPT_CUSTOMREQUEST: + case CURLOPT_FTPPORT: + case CURLOPT_RANGE: + #if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */ + case CURLOPT_FTP_ACCOUNT: + #endif + #if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */ + case CURLOPT_RTSP_SESSION_ID: + #endif + #if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */ + case CURLOPT_KRBLEVEL: #else - goto string_copy; + case CURLOPT_KRB4LEVEL: #endif - } + { + if (Z_TYPE_PP(zvalue) == IS_NULL) { + error = curl_easy_setopt(ch->cp, option, NULL); + } else { + convert_to_string_ex(zvalue); - return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue), 0 TSRMLS_CC); ++ return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRSIZE_PP(zvalue), 0 TSRMLS_CC); } break; } + /* Curl private option */ + case CURLOPT_PRIVATE: + convert_to_string_ex(zvalue); - return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue), 1 TSRMLS_CC); ++ return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRSIZE_PP(zvalue), 1 TSRMLS_CC); + + /* Curl url option */ + case CURLOPT_URL: + convert_to_string_ex(zvalue); - return php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue) TSRMLS_CC); ++ return php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRSIZE_PP(zvalue) TSRMLS_CC); + /* Curl file handle options */ case CURLOPT_FILE: case CURLOPT_INFILE: @@@ -2506,13 -2494,12 +2494,12 @@@ break; case CURLOPT_FOLLOWLOCATION: - convert_to_long_ex(zvalue); + convert_to_int_ex(zvalue); #if LIBCURL_VERSION_NUM < 0x071304 if (PG(open_basedir) && *PG(open_basedir)) { - if (Z_LVAL_PP(zvalue) != 0) { + if (Z_IVAL_PP(zvalue) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set"); - RETVAL_FALSE; - return 1; + return FAILURE; } } #endif @@@ -2677,11 -2660,11 +2660,11 @@@ char *post = NULL; convert_to_string_ex(zvalue); - post = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue)); + post = estrndup(Z_STRVAL_PP(zvalue), Z_STRSIZE_PP(zvalue)); zend_llist_add_element(&ch->to_free->str, &post); - error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, post); + curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, post); - error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, Z_STRLEN_PP(zvalue)); + error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, Z_STRSIZE_PP(zvalue)); #endif } break; @@@ -2778,26 -2761,13 +2761,13 @@@ case CURLOPT_SSH_KNOWNHOSTS: #endif { - #if LIBCURL_VERSION_NUM < 0x071100 - char *copystr = NULL; - #endif - convert_to_string_ex(zvalue); - if (Z_STRLEN_PP(zvalue) && php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) { + if (Z_STRSIZE_PP(zvalue) && php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) { - RETVAL_FALSE; - return 1; + return FAILURE; } - #if LIBCURL_VERSION_NUM >= 0x071100 - error = curl_easy_setopt(ch->cp, option, Z_STRVAL_PP(zvalue)); - #else - copystr = estrndup(Z_STRVAL_PP(zvalue), Z_STRSIZE_PP(zvalue)); - - error = curl_easy_setopt(ch->cp, option, copystr); - zend_llist_add_element(&ch->to_free->str, &copystr); - #endif - break; - return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue), 0 TSRMLS_CC); ++ return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRSIZE_PP(zvalue), 0 TSRMLS_CC); } case CURLINFO_HEADER_OUT: @@@ -2899,7 -2869,7 +2869,7 @@@ PHP_FUNCTION(curl_setopt_array php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array keys must be CURLOPT constants or equivalent integer values"); RETURN_FALSE; } - if (_php_curl_setopt(ch, (php_int_t) option, entry, return_value TSRMLS_CC)) { - if (_php_curl_setopt(ch, (long) option, entry TSRMLS_CC) == FAILURE) { ++ if (_php_curl_setopt(ch, (php_int_t) option, entry TSRMLS_CC) == FAILURE) { RETURN_FALSE; } zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos); diff --cc ext/openssl/openssl.c index a8ca6f5,88ae9a1..5f68e64 mode 100644,100755..100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c diff --cc ext/standard/mail.c index 6aa3e81,b877b87..59fcebe --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@@ -284,9 -284,9 +284,9 @@@ PHPAPI int php_mail(char *to, char *sub php_basename(tmp, strlen(tmp), NULL, 0,&f, &f_len TSRMLS_CC); if (headers != NULL) { - spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n%s", php_getuid(TSRMLS_C), f, headers); + spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_INT_FMT ":%s\n%s", php_getuid(TSRMLS_C), f, headers); } else { - spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_INT_FMT ":%s\n", php_getuid(TSRMLS_C), f); - spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s", php_getuid(TSRMLS_C), f); ++ spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_INT_FMT ":%s", php_getuid(TSRMLS_C), f); } efree(f); } diff --cc ext/standard/string.c index 256ea2f,eafa6cf..4516111 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@@ -5584,12 -5582,11 +5584,11 @@@ PHP_FUNCTION(strpbrk PHP_FUNCTION(substr_compare) { char *s1, *s2; - int s1_len, s2_len; - long offset, len=0; + php_size_t s1_len, s2_len; + php_int_t offset, len=0; zend_bool cs=0; - php_size_t cmp_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|lb", &s1, &s1_len, &s2, &s2_len, &offset, &len, &cs) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSi|ib", &s1, &s1_len, &s2, &s2_len, &offset, &len, &cs) == FAILURE) { RETURN_FALSE; } @@@ -5608,12 -5605,10 +5607,10 @@@ RETURN_FALSE; } - cmp_len = (php_size_t) (len ? len : MAX(s2_len, (s1_len - offset))); - if (!cs) { - RETURN_INT(zend_binary_strncmp(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len)); - RETURN_LONG(zend_binary_strncmp(s1 + offset, (s1_len - offset), s2, s2_len, (uint)len)); ++ RETURN_LONG(zend_binary_strncmp(s1 + offset, (s1_len - offset), s2, s2_len, (php_size_t)len)); } else { - RETURN_INT(zend_binary_strncasecmp_l(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len)); - RETURN_LONG(zend_binary_strncasecmp_l(s1 + offset, (s1_len - offset), s2, s2_len, (uint)len)); ++ RETURN_LONG(zend_binary_strncasecmp_l(s1 + offset, (s1_len - offset), s2, s2_len, (php_size_t)len)); } } /* }}} */ diff --cc ext/standard/tests/strings/substr_compare.phpt index 4644f4c,8477771..e427e96 --- a/ext/standard/tests/strings/substr_compare.phpt +++ b/ext/standard/tests/strings/substr_compare.phpt @@@ -33,9 -35,10 +35,10 @@@ Warning: substr_compare() expects param bool(false) Test - Warning: substr_compare(): The length must be greater than zero in %s on line %d + Warning: substr_compare(): The length must be greater than or equal to zero in %s on line %d bool(false) + int(0) -Warning: substr_compare() expects parameter 4 to be long, string given in %s on line %d +Warning: substr_compare() expects parameter 4 to be integer, string given in %s on line %d bool(false) Done
« previous php.cvs (#76286) next »