mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +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:
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* 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)
|
||||
* will normally be stored unencrypted so that the database
|
||||
@ -775,6 +775,9 @@ destroy_SSL(void)
|
||||
static int
|
||||
open_server_SSL(Port *port)
|
||||
{
|
||||
Assert(!port->ssl);
|
||||
Assert(!port->peer);
|
||||
|
||||
if (!(port->ssl = SSL_new(SSL_context)) ||
|
||||
!my_SSL_set_fd(port->ssl, port->sock) ||
|
||||
SSL_accept(port->ssl) <= 0)
|
||||
@ -821,6 +824,12 @@ close_SSL(Port *port)
|
||||
SSL_free(port->ssl);
|
||||
port->ssl = NULL;
|
||||
}
|
||||
|
||||
if (port->peer)
|
||||
{
|
||||
X509_free(port->peer);
|
||||
port->peer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* The client *requires* a valid server certificate. Since
|
||||
@ -897,6 +897,12 @@ close_SSL(PGconn *conn)
|
||||
SSL_free(conn->ssl);
|
||||
conn->ssl = NULL;
|
||||
}
|
||||
|
||||
if (conn->peer)
|
||||
{
|
||||
X509_free(conn->peer);
|
||||
conn->peer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user