pgsql: In fmtIdEnc(), handle failure of enlargePQExpBuffer().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: In fmtIdEnc(), handle failure of enlargePQExpBuffer().
Date: 2025-02-16 17:46:52
Message-ID: E1tjijE-007TNV-Ag@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

In fmtIdEnc(), handle failure of enlargePQExpBuffer().

Coverity complained that we weren't doing that, and it's right.

This fix just makes fmtIdEnc() honor the general convention that OOM
causes a PQExpBuffer to become marked "broken", without any immediate
error. In the pretty-unlikely case that we actually did hit OOM here,
the end result would be to return an empty string to the caller,
probably resulting in invalid SQL syntax in an issued command (if
nothing else went wrong, which is even more unlikely). It's tempting
to throw an "out of memory" error if the buffer becomes broken, but
there's not a lot of point in doing that only here and not in hundreds
of other PQExpBuffer-using places in pg_dump and similar callers.
The whole issue could do with some non-time-crunched redesign, perhaps.

This is a followup to the fixes for CVE-2025-1094, and should be
included if cherry-picking those fixes.

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3977bd2985de8c5e4b8b00f67dfec28dcfb343c9

Modified Files
--------------
src/fe_utils/string_utils.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-02-16 19:20:51 pgsql: Release notes for 17.4, 16.8, 15.12, 14.17, 13.20.
Previous Message Tom Lane 2025-02-15 21:20:49 pgsql: Make escaping functions retain trailing bytes of an invalid char