1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Back-patch 7.4-era fix for memory leak with SSL connections due to

missing X509_free() calls.  Per a request from a Red Hat customer;
seems silly for Red Hat to be shipping a patch that's not in upstream.
This commit is contained in:
Tom Lane
2006-06-23 14:42:52 +00:00
parent 9e63275633
commit fe090f0778
2 changed files with 17 additions and 2 deletions

View File

@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.15.2.14 2006/05/12 22:45:06 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.15.2.15 2006/06/23 14:42:52 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
@ -775,6 +775,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)) ||
!my_SSL_set_fd(port->ssl, port->sock) || !my_SSL_set_fd(port->ssl, port->sock) ||
SSL_accept(port->ssl) <= 0) SSL_accept(port->ssl) <= 0)
@ -821,6 +824,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;
}
} }
/* /*

View File

@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.15.2.7 2003/08/22 21:57:44 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.15.2.8 2006/06/23 14:42:52 tgl Exp $
* *
* NOTES * NOTES
* The client *requires* a valid server certificate. Since * The client *requires* a valid server certificate. Since
@ -897,6 +897,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;
}
} }
/* /*