]> granicus.if.org Git - php/commitdiff
Fixed bug #38637 (curl_copy_handle() fails to fully copy the cURL handle).
authorIlia Alshanetsky <iliaa@php.net>
Tue, 29 Aug 2006 17:10:40 +0000 (17:10 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 29 Aug 2006 17:10:40 +0000 (17:10 +0000)
NEWS
ext/curl/interface.c

diff --git a/NEWS b/NEWS
index 24c2661fdf5e0032408654993208528ac751d9fb..947dd91d27f9c09ca324277db123ab9cd06138ad 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
   SoapServer::setClass() method). (Dmitry)
 - Added support for hexadecimal entity in imagettftext() for the bundled GD.
   (Pierre)
+- Fixed bug #38637 (curl_copy_handle() fails to fully copy the cURL handle).
+  (Tony, Ilia)
 - Fixed bug #38624 (Strange warning when incrementing an object property and 
   exception is thrown from __get method). (Tony)
 - Fixed bug #38543 (shutdown_executor() may segfault when memory_limit is too
index 888a822e66d2d15630c0dc3df57925464121c731..dccba1ae49278c9564624cf513fa262c5ae17e9e 100644 (file)
@@ -1139,7 +1139,7 @@ PHP_FUNCTION(curl_copy_handle)
        }
 
        alloc_curl_handle(&dupch);
-       TSRMLS_SET_CTX(ch->thread_ctx);
+       TSRMLS_SET_CTX(dupch->thread_ctx);
 
        dupch->cp = cp;
        dupch->handlers->write->method = ch->handlers->write->method;
@@ -1147,6 +1147,38 @@ PHP_FUNCTION(curl_copy_handle)
        dupch->handlers->read->method  = ch->handlers->read->method;
        dupch->handlers->write_header->method = ch->handlers->write_header->method;
 
+       dupch->handlers->write->fp = ch->handlers->write->fp;
+       dupch->handlers->write_header->fp = ch->handlers->write_header->fp;
+       dupch->handlers->read->fp = ch->handlers->read->fp;
+       dupch->handlers->read->fd = ch->handlers->read->fd;
+
+       if (ch->handlers->passwd) {
+               zval_add_ref(&ch->handlers->passwd);
+               dupch->handlers->passwd = ch->handlers->passwd;
+               curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) dupch);
+       }
+       if (ch->handlers->write->func_name) {
+               zval_add_ref(&ch->handlers->write->func_name);
+               dupch->handlers->write->func_name = ch->handlers->write->func_name;
+       }
+       if (ch->handlers->read->func_name) {
+               zval_add_ref(&ch->handlers->read->func_name);
+               dupch->handlers->read->func_name = ch->handlers->read->func_name;
+       }
+       if (ch->handlers->write_header->func_name) {
+               zval_add_ref(&ch->handlers->write_header->func_name);
+               dupch->handlers->write_header->func_name = ch->handlers->write_header->func_name;
+       }
+
+       curl_easy_setopt(dupch->cp, CURLOPT_ERRORBUFFER,       dupch->err.str);
+       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);
+
+       zend_llist_copy(&dupch->to_free.str, &ch->to_free.str);
+       zend_llist_copy(&dupch->to_free.slist, &ch->to_free.slist);
+       zend_llist_copy(&dupch->to_free.post, &ch->to_free.post);
+
        ZEND_REGISTER_RESOURCE(return_value, dupch, le_curl);
        dupch->id = Z_LVAL_P(return_value);
 }