Skip to content

Commit 2805e1c

Browse files
committed
ecpg: Fix NULL pointer dereference during connection lookup
ECPGconnect() caches established connections to the server, supporting the case of a NULL connection name when a database name is not specified by its caller. A follow-up call to ECPGget_PGconn() to get an established connection from the cached set with a non-NULL name could cause a NULL pointer dereference if a NULL connection was listed in the cache and checked for a match. At least two connections are necessary to reproduce the issue: one with a NULL name and one with a non-NULL name. Author: Aleksander Alekseev <aleksander@tigerdata.com> Discussion: https://postgr.es/m/CAJ7c6TNvFTPUTZQuNAoqgzaSGz-iM4XR61D7vEj5PsQXwg2RyA@mail.gmail.com Backpatch-through: 13
1 parent 6b755d8 commit 2805e1c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ ecpg_get_connection_nr(const char *connection_name)
5858

5959
for (con = all_connections; con != NULL; con = con->next)
6060
{
61-
if (strcmp(connection_name, con->name) == 0)
61+
/*
62+
* Check for the case of a NULL connection name, stored as such in
63+
* the connection information by ECPGconnect() when the database
64+
* name is not specified by its caller.
65+
*/
66+
if (con->name != NULL && strcmp(connection_name, con->name) == 0)
6267
break;
6368
}
6469
ret = con;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy