提交 e0cd1752 编写于 作者: T Tom Lane

Fix memory leak with SSL connections due to missing X509_free() calls.

Per Neil Conway.
上级 54840eca
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.44 2003/11/29 19:51:49 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.45 2003/12/18 22:49:26 tgl Exp $
* *
* Since the server static private key ($DataDir/server.key) * Since the server static private key ($DataDir/server.key)
* will normally be stored unencrypted so that the database * will normally be stored unencrypted so that the database
...@@ -714,6 +714,9 @@ destroy_SSL(void) ...@@ -714,6 +714,9 @@ destroy_SSL(void)
static int static int
open_server_SSL(Port *port) open_server_SSL(Port *port)
{ {
Assert(!port->ssl);
Assert(!port->peer);
if (!(port->ssl = SSL_new(SSL_context)) || if (!(port->ssl = SSL_new(SSL_context)) ||
!SSL_set_fd(port->ssl, port->sock) || !SSL_set_fd(port->ssl, port->sock) ||
SSL_accept(port->ssl) <= 0) SSL_accept(port->ssl) <= 0)
...@@ -764,6 +767,12 @@ close_SSL(Port *port) ...@@ -764,6 +767,12 @@ close_SSL(Port *port)
SSL_free(port->ssl); SSL_free(port->ssl);
port->ssl = NULL; port->ssl = NULL;
} }
if (port->peer)
{
X509_free(port->peer);
port->peer = NULL;
}
} }
/* /*
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.33 2003/11/29 19:52:12 pgsql Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.34 2003/12/18 22:49:26 tgl Exp $
* *
* NOTES * NOTES
* The client *requires* a valid server certificate. Since * The client *requires* a valid server certificate. Since
...@@ -1004,6 +1004,12 @@ close_SSL(PGconn *conn) ...@@ -1004,6 +1004,12 @@ close_SSL(PGconn *conn)
SSL_free(conn->ssl); SSL_free(conn->ssl);
conn->ssl = NULL; conn->ssl = NULL;
} }
if (conn->peer)
{
X509_free(conn->peer);
conn->peer = NULL;
}
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册