pgsql: Fix potential NULL pointer dereference in getIdentitySequence() - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Fix potential NULL pointer dereference in getIdentitySequence()
Date
Msg-id E1sBCWU-001pvr-Ot@gemulon.postgresql.org
Whole thread Raw
Responses Re: pgsql: Fix potential NULL pointer dereference in getIdentitySequence()
List 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(-)


pgsql-committers by date:

Previous
From: Alexander Korotkov
Date:
Subject: pgsql: amcheck: Fixes for right page check during unique constraint che
Next
From: Andrew Dunstan
Date:
Subject: Re: pgsql: Fix potential NULL pointer dereference in getIdentitySequence()