com php-src: - Bug #65228 (FTPs memory leak) patch by: marco dot beierer at mbsecurity dot ch: ext/ftp/ftp.c
| From: | Felipe Pena | Date: | Sat, 13 Jul 2013 20:54:31 +0000 |
| Subject: | com php-src: - Bug #65228 (FTPs memory leak) patch by: marco dot beierer at mbsecurity dot ch: ext/ftp/ftp.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-72629@lists.php.net to get a copy of this message | ||
Commit: 0863a0d6a0f740874b4ef8dc732a4ec94949470c
Author: Felipe Pena <felipensp@gmail.com> Sat, 13 Jul 2013 17:54:31 -0300
Parents: 281936b29535ae095350abb274acef0ae548a431
Branches: PHP-5.4 PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0863a0d6a0f740874b4ef8dc732a4ec94949470c
Log:
- Bug #65228 (FTPs memory leak) patch by: marco dot beierer at mbsecurity dot ch
Bugs:
https://bugs.php.net/65228
Changed paths:
M ext/ftp/ftp.c
Diff:
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index 4c8a94f..bde4792 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -182,6 +182,7 @@ ftp_close(ftpbuf_t *ftp)
#if HAVE_OPENSSL_EXT
if (ftp->ssl_active) {
SSL_shutdown(ftp->ssl_handle);
+ SSL_free(ftp->ssl_handle);
}
#endif
closesocket(ftp->fd);
@@ -297,6 +298,7 @@ ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
if (SSL_connect(ftp->ssl_handle) <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL/TLS handshake failed");
SSL_shutdown(ftp->ssl_handle);
+ SSL_free(ftp->ssl_handle);
return 0;
}
@@ -1548,6 +1550,7 @@ data_accepted:
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;
}
@@ -1565,13 +1568,21 @@ data_accepted:
databuf_t*
data_close(ftpbuf_t *ftp, databuf_t *data)
{
+#if HAVE_OPENSSL_EXT
+ SSL_CTX *ctx;
+#endif
if (data == NULL) {
return NULL;
}
if (data->listener != -1) {
#if HAVE_OPENSSL_EXT
if (data->ssl_active) {
+
+ ctx = SSL_get_SSL_CTX(data->ssl_handle);
+ SSL_CTX_free(ctx);
+
SSL_shutdown(data->ssl_handle);
+ SSL_free(data->ssl_handle);
data->ssl_active = 0;
}
#endif
@@ -1580,7 +1591,11 @@ data_close(ftpbuf_t *ftp, databuf_t *data)
if (data->fd != -1) {
#if HAVE_OPENSSL_EXT
if (data->ssl_active) {
+ ctx = SSL_get_SSL_CTX(data->ssl_handle);
+ SSL_CTX_free(ctx);
+
SSL_shutdown(data->ssl_handle);
+ SSL_free(data->ssl_handle);
data->ssl_active = 0;
}
#endif