pg_dump: avoid assuming how long pg_proc.protrftypes can be. The backend doesn't impose any particular limit on the length of this array, and since there could be entries for both input and output arguments, it's feasible for the length to exceed FUNC_MAX_ARGS even without funny business. This could lead to crashes or worse.
Moreover, pg_dump shouldn't rely on hard-coding FUNC_MAX_ARGS in the first place: it has no business assuming that the backend it's dumping from was compiled with the same value of FUNC_MAX_ARGS that it is. So the stanza in dumpFunc() that allocates exactly FUNC_MAX_ARGS space for the parsed OID array is fundamentally misguided. And it's broken in another way too: if there are exactly FUNC_MAX_ARGS OIDs, then parseOidArray won't zero-fill any entries, allowing the subsequent loop to run off the end of the array. A crash seems unlikely in this variant, but garbage output is certain. To fix, redesign parseOidArray's API so that it does the array-mallocing, which simplifies the callers anyway. While we're here, tighten and modernize it a bit; in particular, split it into separate functions for OIDs and integers, as was foreseen long ago. This lets us get rid of the confusing type-punning involved in having IndxInfo.indkeys be declared as "Oid *" when it's really potentially-signed ints. Also, most of the callers expect an exact number of array entries, so make it verify that not just check for "too many". I noted while testing that this dumpFunc() stanza isn't even reached during check-world. Add a function with transform to the regression tests to rectify that. Reported-by: Masahiko Sawada <[email protected]> Author: Tom Lane <[email protected]> Reviewed-by: Masahiko Sawada <[email protected]> Backpatch-through: 14 Security: CVE-2026-19385 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3299c2ba0cc5034d102eaf2f146e2794e00620e1 Author: Tom Lane <[email protected]> Modified Files -------------- src/bin/pg_dump/common.c | 142 ++++++++++++++++++++++----- src/bin/pg_dump/pg_dump.c | 30 ++---- src/bin/pg_dump/pg_dump.h | 5 +- src/test/regress/expected/object_address.out | 4 + src/test/regress/sql/object_address.sql | 4 + 5 files changed, 140 insertions(+), 45 deletions(-)
