pgsql: Fix potential NULL pointer dereference in getIdentitySequence()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix potential NULL pointer dereference in getIdentitySequence()
Date: 2024-05-26 11:58:46
Message-ID: E1sBCWU-001pvr-Ot@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix potential NULL pointer dereference in getIdentitySequence()

The function invokes SearchSysCacheAttNum() and SearchSysCacheAttName().
They may respectively return 0 for the attribute number or NULL for
the attribute name if the attribute does not exist, without any kind of
error handling. The common practice is to check that the data retrieved
from the syscache is valid. There is no risk of NULL pointer
dereferences currently, but let's stick to the practice of making sure
that this data is always valid, to catch future inconsistency mistakes.
The code is switched to use get_attnum() and get_attname(), and adds
some error handling.

Oversight in 509199587df7.

Reported-by: Ranier Vilela
Author: Ashutosh Bapat
Discussion: https://postgr.es/m/CAEudQAqh_RZqoFcYKso5d9VhF-Vd64_ZodfQ_2zSusszkEmyRg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8285b484a47d829a29fbe0ebe65cdc9f9dfb179d

Modified Files
--------------
src/backend/catalog/pg_depend.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2024-05-26 21:33:27 Re: pgsql: Fix potential NULL pointer dereference in getIdentitySequence()
Previous Message Alexander Korotkov 2024-05-26 04:14:27 pgsql: amcheck: Fixes for right page check during unique constraint che