]> granicus.if.org Git - php/commitdiff
Fix SSL_CTX leak in ftp extension
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 25 Jun 2019 10:09:47 +0000 (12:09 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 25 Jun 2019 12:28:58 +0000 (14:28 +0200)
SSL_CTX is a refcounted structure, which will be held by the SSL
handle, so we can free it here.

ext/ftp/ftp.c

index b1343976b668c9dc9cec0d3ef5ec788704d52fa4..e5355b1bd4f3f53e3d792f2c477f338cfe82d148 100644 (file)
@@ -287,9 +287,10 @@ ftp_login(ftpbuf_t *ftp, const char *user, const size_t user_len, const char *pa
                SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH);
 
                ftp->ssl_handle = SSL_new(ctx);
+               SSL_CTX_free(ctx);
+
                if (ftp->ssl_handle == NULL) {
                        php_error_docref(NULL, E_WARNING, "failed to create the SSL handle");
-                       SSL_CTX_free(ctx);
                        return 0;
                }