com php-src: Merge branch 'PHP-5.6' into PHP-7.0: NEWS ext/ftp/ftp.c
| From: | Nikita Popov | Date: | Sat, 13 Aug 2016 19:41:00 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.6' into PHP-7.0: NEWS ext/ftp/ftp.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93771@lists.php.net to get a copy of this message | ||
Commit: 98787d90020c7b21c1dd5d1701e6157993d02aec
Author: Nikita Popov <nikic@php.net> Sat, 13 Aug 2016 21:41:00 +0200
Parents: 33508a3d4730f8d15d37e2e5c4c2b18a545fd989 dfadc5a427b548cab2b7c037c05f65684e08a248
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=98787d90020c7b21c1dd5d1701e6157993d02aec
Log:
Merge branch 'PHP-5.6' into PHP-7.0
Changed paths:
MM NEWS
MM ext/ftp/ftp.c
Diff:
diff --cc NEWS
index 9bea75e,ccafb63..3582cce
--- a/NEWS
+++ b/NEWS
@@@ -1,23 -1,15 +1,27 @@@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-?? ??? 2016, PHP 5.6.26
+?? ??? 2016 PHP 7.0.11
+
+- Core:
+ . Fixed bug #72813 (Segfault with __get returned by ref). (Laruence)
+ . Fixed bug #72767 (PHP Segfaults when trying to expand an infinite operator).
+ (Nikita)
+ - FTP:
+ . Fixed bug #70195 (Cannot upload file using ftp_put to FTPES with
+ require_ssl_reuse). (Benedict Singer)
+
-- MSSQL:
- . Fixed bug #72039 (Use of uninitialised value on mssql_guid_string). (Kalle)
+- GD:
+ . Fixed bug #72709 (imagesetstyle() causes OOB read for empty $styles). (cmb)
+
+- OCI8
+ . Fixed invalid handle error with Implicit Result Sets. (Chris Jones)
+ . Fixed bug #72524 (Binding null values triggers ORA-24816 error). (Chris Jones)
- PDO:
+ . Fixed bug #72788 (Invalid memory access when using persistent PDO
+ connection). (Keyur)
+ . Fixed bug #72791 (Memory leak in PDO persistent connection handling). (Keyur)
. Fixed bug #60665 (call to empty() on NULL result using PDO::FETCH_LAZY
returns false). (cmb)
diff --cc ext/ftp/ftp.c
index b3548e7,d2f726d..df80691
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@@ -291,9 -290,12 +291,12 @@@ ftp_login(ftpbuf_t *ftp, const char *us
#endif
SSL_CTX_set_options(ctx, ssl_ctx_options);
+ /* allow SSL to re-use sessions */
+ SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH);
+
ftp->ssl_handle = SSL_new(ctx);
if (ftp->ssl_handle == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to create the SSL handle");
+ php_error_docref(NULL, E_WARNING, "failed to create the SSL handle");
SSL_CTX_free(ctx);
return 0;
}
@@@ -1635,11 -1496,10 +1638,11 @@@ data_accept(databuf_t *data, ftpbuf_t *
php_sockaddr_storage addr;
socklen_t size;
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
SSL_CTX *ctx;
- zend_long ssl_ctx_options = SSL_OP_ALL;
+ SSL_SESSION *session;
- int result;
+ int err, res;
+ zend_bool retry;
#endif
if (data->fd != -1) {
@@@ -1660,21 -1520,15 +1663,15 @@@ data_accepted
/* now enable ssl if we need to */
if (ftp->use_ssl && ftp->use_ssl_for_data) {
- ctx = SSL_CTX_new(SSLv23_client_method());
+ ctx = SSL_get_SSL_CTX(ftp->ssl_handle);
if (ctx == NULL) {
- php_error_docref(NULL, E_WARNING, "data_accept: failed to create the SSL context");
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: failed to retreive the existing
SSL context");
++ php_error_docref(NULL, E_WARNING, "data_accept: failed to retreive the existing SSL
context");
return 0;
}
- #if OPENSSL_VERSION_NUMBER >= 0x0090605fL
- ssl_ctx_options &= ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
- #endif
- SSL_CTX_set_options(ctx, ssl_ctx_options);
-
data->ssl_handle = SSL_new(ctx);
if (data->ssl_handle == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: failed to create the SSL
handle");
+ php_error_docref(NULL, E_WARNING, "data_accept: failed to create the SSL handle");
- SSL_CTX_free(ctx);
return 0;
}
@@@ -1685,42 -1538,28 +1681,58 @@@
SSL_copy_session_id(data->ssl_handle, ftp->ssl_handle);
}
+ /* get the session from the control connection so we can re-use it */
+ session = SSL_get_session(ftp->ssl_handle);
+ if (session == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: failed to retreive the existing
SSL session");
++ php_error_docref(NULL, E_WARNING, "data_accept: failed to retreive the existing SSL
session");
+ SSL_free(data->ssl_handle);
+ return 0;
+ }
+
+ /* and set it on the data connection */
- result = SSL_set_session(data->ssl_handle, session);
- if (result == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: failed to set the existing SSL
session");
++ res = SSL_set_session(data->ssl_handle, session);
++ if (res == 0) {
++ php_error_docref(NULL, E_WARNING, "data_accept: failed to set the existing SSL
session");
+ SSL_free(data->ssl_handle);
+ return 0;
+ }
+
- if (SSL_connect(data->ssl_handle) <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: SSL/TLS handshake failed");
- SSL_shutdown(data->ssl_handle);
- SSL_free(data->ssl_handle);
- return 0;
- }
+ do {
+ res = SSL_connect(data->ssl_handle);
+ err = SSL_get_error(data->ssl_handle, res);
+
+ switch (err) {
+ case SSL_ERROR_NONE:
+ retry = 0;
+ break;
+
+ case SSL_ERROR_ZERO_RETURN:
+ retry = 0;
+ SSL_shutdown(data->ssl_handle);
+ break;
+
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE: {
+ php_pollfd p;
+ int i;
+
+ p.fd = ftp->fd;
+ p.events = (err == SSL_ERROR_WANT_READ) ? (POLLIN|POLLPRI) : POLLOUT;
+ p.revents = 0;
+
+ i = php_poll2(&p, 1, 300);
+
+ retry = i > 0;
+ }
+ break;
+
+ default:
+ php_error_docref(NULL, E_WARNING, "data_accept: SSL/TLS handshake failed");
+ SSL_shutdown(data->ssl_handle);
+ SSL_free(data->ssl_handle);
+ return 0;
+ }
+ } while (retry);
data->ssl_active = 1;
}
@@@ -1743,12 -1582,9 +1755,9 @@@ data_close(ftpbuf_t *ftp, databuf_t *da
return NULL;
}
if (data->listener != -1) {
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
if (data->ssl_active) {
-
- ctx = SSL_get_SSL_CTX(data->ssl_handle);
- SSL_CTX_free(ctx);
-
+ /* don't free the data context, it's the same as the control */
SSL_shutdown(data->ssl_handle);
SSL_free(data->ssl_handle);
data->ssl_active = 0;
@@@ -1757,11 -1593,9 +1766,9 @@@
closesocket(data->listener);
}
if (data->fd != -1) {
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
if (data->ssl_active) {
- ctx = SSL_get_SSL_CTX(data->ssl_handle);
- SSL_CTX_free(ctx);
-
+ /* don't free the data context, it's the same as the control */
SSL_shutdown(data->ssl_handle);
SSL_free(data->ssl_handle);
data->ssl_active = 0;