]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.4' into PHP-5.5
authorAdam Harvey <aharvey@php.net>
Mon, 19 Aug 2013 19:16:36 +0000 (12:16 -0700)
committerAdam Harvey <aharvey@php.net>
Mon, 19 Aug 2013 19:16:36 +0000 (12:16 -0700)
* PHP-5.4:
  Track created curl_slist structs by option so they can be updated in situ.

Conflicts:
ext/curl/interface.c

1  2 
NEWS
ext/curl/interface.c
ext/curl/php_curl.h

diff --cc NEWS
index d5d2cda7e4b3e3e07b2f852b2f6095f84002e934,64e049d70d134216c07de04cdd1aa392021e4247..634e6b9a802991118e2133ced9ae9bded04e15eb
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,25 -1,12 +1,28 @@@
  PHP                                                                        NEWS
  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 -?? ??? 2013, PHP 5.4.19
 +?? ??? 2013, PHP 5.5.3
  
  - Core:
 -  . Fixed bug #65470 (Segmentation fault in zend_error() with 
 +  . Fixed bug #65470 (Segmentation fault in zend_error() with
      --enable-dtrace). (Chris Jones)
 +  . Fixed bug #65225 (PHP_BINARY incorrectly set). (Patrick Allaert)
 +  . Fixed bug #62692 (PHP fails to build with DTrace). (Chris Jones, Kris Van Hees)
 +
++- cURL:
++  . Fixed bug #65458 (curl memory leak). (Adam)
++
 +- Openssl:
 +  . Fixed bug #64802 (openssl_x509_parse fails to parse subject properly in
 +    some cases). (Mark Jones)
 +
 +15 Aug 2013, PHP 5.5.2
 +
 +- Core:
    . Fixed bug #65372 (Segfault in gc_zval_possible_root when return reference
      fails). (Laruence)
 +  . Fixed value of FILTER_SANITIZE_FULL_SPECIAL_CHARS constant (previously was
 +    erroneously set to FILTER_SANITIZE_SPECIAL_CHARS value). (Andrey
 +    avp200681 gmail com).
    . Fixed bug #65304 (Use of max int in array_sum). (Laruence)
    . Fixed bug #65291 (get_defined_constants() causes PHP to crash in a very
      limited case). (Arpad)
index 4b6e5e27dc6eccd28b4f3871919f38335ca8fbd7,f79d0d54c2e0156bca84f69ef0646521512ff243..861795485d1c02163ec2276c566ac60c56227695
@@@ -1790,9 -1443,10 +1790,11 @@@ static void alloc_curl_handle(php_curl 
        (*ch)->handlers->read->stream = NULL;
  
        zend_llist_init(&(*ch)->to_free->str,   sizeof(char *),            (llist_dtor_func_t) curl_free_string, 0);
-       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);
 +      (*ch)->safe_upload = 0; /* for now, for BC reason we allow unsafe API */
+       (*ch)->to_free->slist = emalloc(sizeof(HashTable));
+       zend_hash_init((*ch)->to_free->slist, 4, NULL, curl_free_slist, 0);
  }
  /* }}} */
  
@@@ -2019,30 -1675,9 +2021,31 @@@ PHP_FUNCTION(curl_copy_handle
        curl_easy_setopt(dupch->cp, CURLOPT_FILE,              (void *) dupch);
        curl_easy_setopt(dupch->cp, CURLOPT_INFILE,            (void *) dupch);
        curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER,       (void *) dupch);
 -      curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA,      (void *) dupch); 
 +
 +      if (ch->handlers->progress) {
 +              dupch->handlers->progress = ecalloc(1, sizeof(php_curl_progress));
 +              if (ch->handlers->progress->func_name) {
 +                      zval_add_ref(&ch->handlers->progress->func_name);
 +                      dupch->handlers->progress->func_name = ch->handlers->progress->func_name;
 +              }
 +              dupch->handlers->progress->method = ch->handlers->progress->method;
 +              curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch);
 +      }
 +
 +/* Available since 7.21.0 */
 +#if LIBCURL_VERSION_NUM >= 0x071500
 +      if (ch->handlers->fnmatch) {
 +              dupch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch));
 +              if (ch->handlers->fnmatch->func_name) {
 +                      zval_add_ref(&ch->handlers->fnmatch->func_name);
 +                      dupch->handlers->fnmatch->func_name = ch->handlers->fnmatch->func_name;
 +              }
 +              dupch->handlers->fnmatch->method = ch->handlers->fnmatch->method;
 +              curl_easy_setopt(dupch->cp, CURLOPT_FNMATCH_DATA, (void *) dupch);
 +      }
 +#endif
  
+       efree(dupch->to_free->slist);
        efree(dupch->to_free);
        dupch->to_free = ch->to_free;
  
@@@ -2415,102 -1973,56 +2418,102 @@@ string_copy
                                        error = curl_easy_setopt(ch->cp, option, fp);
                                        break;
                        }
 -
                        break;
                }
 -              case CURLOPT_RETURNTRANSFER:
 -                      convert_to_long_ex(zvalue);
  
 -                      if (Z_LVAL_PP(zvalue)) {
 -                              ch->handlers->write->method = PHP_CURL_RETURN;
 -                      } else {
 -                              ch->handlers->write->method = PHP_CURL_STDOUT;
 -                      }
 -                      break;
 -              case CURLOPT_BINARYTRANSFER:
 -                      convert_to_long_ex(zvalue);
 +              /* Curl linked list options */
 +              case CURLOPT_HTTP200ALIASES:
 +              case CURLOPT_HTTPHEADER:
 +              case CURLOPT_POSTQUOTE:
 +              case CURLOPT_PREQUOTE:
 +              case CURLOPT_QUOTE:
 +              case CURLOPT_TELNETOPTIONS:
 +#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
 +              case CURLOPT_MAIL_RCPT:
 +#endif
 +#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
 +              case CURLOPT_RESOLVE:
 +#endif
 +              {
 +                      zval              **current;
 +                      HashTable          *ph;
 +                      struct curl_slist  *slist = NULL;
  
 -                      if (Z_LVAL_PP(zvalue)) {
 -                              ch->handlers->write->type = PHP_CURL_BINARY;
 -                      } else {
 -                              ch->handlers->write->type = PHP_CURL_ASCII;
 +                      ph = HASH_OF(*zvalue);
 +                      if (!ph) {
 +                              char *name;
 +                              switch (option) {
 +                                      case CURLOPT_HTTPHEADER:
 +                                              name = "CURLOPT_HTTPHEADER";
 +                                              break;
 +                                      case CURLOPT_QUOTE:
 +                                              name = "CURLOPT_QUOTE";
 +                                              break;
 +                                      case CURLOPT_HTTP200ALIASES:
 +                                              name = "CURLOPT_HTTP200ALIASES";
 +                                              break;
 +                                      case CURLOPT_POSTQUOTE:
 +                                              name = "CURLOPT_POSTQUOTE";
 +                                              break;
 +                                      case CURLOPT_PREQUOTE:
 +                                              name = "CURLOPT_PREQUOTE";
 +                                              break;
 +                                      case CURLOPT_TELNETOPTIONS:
 +                                              name = "CURLOPT_TELNETOPTIONS";
 +                                              break;
 +#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
 +                                      case CURLOPT_MAIL_RCPT:
 +                                              name = "CURLOPT_MAIL_RCPT";
 +                                              break;
 +#endif
 +#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
 +                                      case CURLOPT_RESOLVE:
 +                                              name = "CURLOPT_RESOLVE";
 +                                              break;
 +#endif
 +                              }
 +                              php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must pass either an object or an array with the %s argument", name);
 +                              RETVAL_FALSE;
 +                              return 1;
                        }
 -                      break;
 -              case CURLOPT_WRITEFUNCTION:
 -                      if (ch->handlers->write->func_name) {
 -                              zval_ptr_dtor(&ch->handlers->write->func_name);
 -                              ch->handlers->write->fci_cache = empty_fcall_info_cache;
 +
 +                      for (zend_hash_internal_pointer_reset(ph);
 +                               zend_hash_get_current_data(ph, (void **) &current) == SUCCESS;
 +                               zend_hash_move_forward(ph)
 +                      ) {
 +                              SEPARATE_ZVAL(current);
 +                              convert_to_string_ex(current);
 +
 +                              slist = curl_slist_append(slist, Z_STRVAL_PP(current));
 +                              if (!slist) {
 +                                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not build curl_slist");
 +                                      RETVAL_FALSE;
 +                                      return 1;
 +                              }
                        }
-                       zend_llist_add_element(&ch->to_free->slist, &slist);
 -                      zval_add_ref(zvalue);
 -                      ch->handlers->write->func_name = *zvalue;
 -                      ch->handlers->write->method = PHP_CURL_USER;
++                      zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NULL);
 +
 +                      error = curl_easy_setopt(ch->cp, option, slist);
 +
                        break;
 -              case CURLOPT_READFUNCTION:
 -                      if (ch->handlers->read->func_name) {
 -                              zval_ptr_dtor(&ch->handlers->read->func_name);
 -                              ch->handlers->read->fci_cache = empty_fcall_info_cache;
 -                      }
 -                      zval_add_ref(zvalue);
 -                      ch->handlers->read->func_name = *zvalue;
 -                      ch->handlers->read->method = PHP_CURL_USER;
 +              }
 +
 +              case CURLOPT_BINARYTRANSFER:
 +                      /* Do nothing, just backward compatibility */
                        break;
 -              case CURLOPT_PROGRESSFUNCTION:
 -                      curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION,      curl_progress);
 -                      curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch);
 -                      if (ch->handlers->progress->func_name) {
 -                              zval_ptr_dtor(&ch->handlers->progress->func_name);
 -                              ch->handlers->progress->fci_cache = empty_fcall_info_cache;
 +
 +              case CURLOPT_FOLLOWLOCATION:
 +                      convert_to_long_ex(zvalue);
 +                      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 an open_basedir is set");
 +                                      RETVAL_FALSE;
 +                                      return 1;
 +                              }
                        }
 -                      zval_add_ref(zvalue);
 -                      ch->handlers->progress->func_name = *zvalue;
 -                      ch->handlers->progress->method = PHP_CURL_USER;
 +                      error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
                        break;
 +
                case CURLOPT_HEADERFUNCTION:
                        if (ch->handlers->write_header->func_name) {
                                zval_ptr_dtor(&ch->handlers->write_header->func_name);
Simple merge