mirror of
https://github.com/postgres/postgres.git
synced 2025-05-18 17:41:14 +03:00
Fix memory leak with SSL connections due to missing X509_free() calls.
Per Neil Conway.
This commit is contained in:
parent
cf88f005f2
commit
7748c5ee29
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.43 2003/09/26 15:27:31 petere Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.43.2.1 2003/12/18 22:49:34 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)
|
|||||||
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)
|
|||||||
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 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.32 2003/09/29 16:38:04 petere Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.32.2.1 2003/12/18 22:49:34 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)
|
|||||||
SSL_free(conn->ssl);
|
SSL_free(conn->ssl);
|
||||||
conn->ssl = NULL;
|
conn->ssl = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (conn->peer)
|
||||||
|
{
|
||||||
|
X509_free(conn->peer);
|
||||||
|
conn->peer = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user