Re: Avoid possible dereference null pointer (src/backend/catalog/pg_depend.c) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Re: Avoid possible dereference null pointer (src/backend/catalog/pg_depend.c)
Date
Msg-id CAEudQAr5_vYbgz0dHXcqO4RZB+RwQPFAnH+UVt_qatFaooeoyA@mail.gmail.com
Whole thread Raw
In response to Re: Avoid possible dereference null pointer (src/backend/catalog/pg_depend.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Responses Re: Avoid possible dereference null pointer (src/backend/catalog/pg_depend.c)
List pgsql-hackers
Em qua., 22 de mai. de 2024 às 13:09, Ranier Vilela <ranier.vf@gmail.com> escreveu:
Em qua., 22 de mai. de 2024 às 11:44, Ranier Vilela <ranier.vf@gmail.com> escreveu:
Hi.

Per Coverity.
     
2. returned_null: SearchSysCacheAttName returns NULL (checked 20 out of 21 times).
3. var_assigned: Assigning: ptup = NULL return value from SearchSysCacheAttName.
 964                ptup = SearchSysCacheAttName(relidattname);
CID 1545986: (#1 of 1): Dereference null return value (NULL_RETURNS)
4. dereference: Dereferencing ptup, which is known to be NULL.

The functions SearchSysCacheAttNum and SearchSysCacheAttName,
need to have the result checked.

The commit 5091995, left an oversight.

Fixed by the patch attached, a change of style, unfortunately, was necessary.
v1 Attached, fix wrong column variable name in error report.
1. Another concern is the function *get_partition_ancestors*,
which may return NIL, which may affect *llast_oid*, which does not handle NIL entries.

2. Is checking *relispartition* enough?
There a function *check_rel_can_be_partition* (src/backend/utils/adt/partitionfuncs.c),
which performs a much more robust check, would it be worth using it?

With the v2 attached, 1 is handled, but, in this case,
will it be the most correct?

best regards,
Ranier Vilela
Attachment

pgsql-hackers by date:

Previous
From: walther@technowledgy.de
Date:
Subject: Re: Schema variables - new implementation for Postgres 15
Next
From: Pavel Stehule
Date:
Subject: Re: Schema variables - new implementation for Postgres 15