pgsql: ecpg: Fix NULL pointer dereference during connection lookup

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: ecpg: Fix NULL pointer dereference during connection lookup
Date: 2025-07-22 05:00:43
Message-ID: E1ue57L-0008Zh-1h@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)tigerdata(dot)com>
Discussion: https://postgr.es/m/CAJ7c6TNvFTPUTZQuNAoqgzaSGz-iM4XR61D7vEj5PsQXwg2RyA@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2805e1c1edd5f5c59d40f85f8a32d26f9ccb10a6

Modified Files
--------------
src/interfaces/ecpg/ecpglib/connect.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2025-07-22 05:22:46 pgsql: Log remote NOTICE, WARNING, and similar messages using ereport()
Previous Message Richard Guo 2025-07-22 02:23:08 pgsql: Centralize collection of catalog info needed early in the planne