postgresql/src/backend
Tom Lane 4f4a422fbb Compute aggregate argument types correctly in transformAggregateCall().
transformAggregateCall() captures the datatypes of the aggregate's
arguments immediately to construct the Aggref.aggargtypes list.
This seems reasonable because the arguments have already been
transformed --- but there is an edge case where they haven't been.
Specifically, if we have an unknown-type literal in an ANY argument
position, nothing will have been done with it earlier.  But if we
also have DISTINCT, then addTargetToGroupList() converts the literal
to "text" type, resulting in the aggargtypes list not matching the
actual runtime type of the argument.  The end result is that the
aggregate tries to interpret a "text" value as being of type
"unknown", that is a zero-terminated C string.  If the text value
contains no zero bytes, this could result in disclosure of server
memory following the text literal value.

To fix, move the collection of the aggargtypes list to the end
of transformAggregateCall(), after DISTINCT has been handled.
This requires slightly more code, but not a great deal.

Our thanks to Jingzhou Fu for reporting this problem.

Security: CVE-2023-5868
2023-11-06 10:38:00 -05:00
..
access doc: 1-byte varlena headers can be used for user PLAIN storage 2023-10-31 09:10:35 -04:00
backup In basebackup.c, perform end-of-file test after checksum validation. 2023-03-06 10:20:17 -05:00
bootstrap Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
catalog Fix checking of index expressions in CompareIndexInfo(). 2023-09-28 14:05:25 -04:00
commands Ensure we have a snapshot while dropping ON COMMIT DROP temp tables. 2023-10-16 14:06:15 -04:00
executor Fix intra-query memory leak when a SRF returns zero rows. 2023-10-28 14:04:43 -04:00
foreign Rename SetSingleFuncCall() to InitMaterializedSRF() 2022-10-18 10:22:40 +09:00
jit jit: Changes for LLVM 17. 2023-10-19 05:15:38 +13:00
lib Fix lock assertions in dshash.c. 2022-07-11 16:01:22 +12:00
libpq Avoid potential pfree on NULL on OpenSSL errors 2023-09-22 11:18:25 +02:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:32 +09:00
nodes Remove inappropriate raw_expression_tree_walker() code 2023-06-29 10:35:35 +02:00
optimizer Fix problems when a plain-inheritance parent table is excluded. 2023-10-24 14:48:34 -04:00
parser Compute aggregate argument types correctly in transformAggregateCall(). 2023-11-06 10:38:00 -05:00
partitioning Fix incorrect step generation in HASH partition pruning 2023-10-12 19:52:05 +13:00
po Translation updates 2023-11-06 13:16:22 +01:00
port Ensure that the argument of shmdt(2) is declared "void *". 2022-02-15 17:17:28 -05:00
postmaster Avoid calling proc_exit() in processes forked by system(). 2023-10-17 10:42:06 -05:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:20:17 -07:00
replication Fix uninitialized access to InitialRunningXacts during decoding after ERROR. 2023-09-12 10:23:17 +05:30
rewrite Fix RLS policy usage in MERGE. 2023-08-07 09:24:27 +01:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Remove unnecessary code in dependency_is_compatible_expression(). 2023-03-14 11:10:45 -04:00
storage Ban role pg_signal_backend from more superuser backend types. 2023-11-06 06:14:16 -08:00
tcop Be more rigorous about local variables in PostgresMain(). 2023-07-10 12:14:34 -04:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Set GUC "is_superuser" in all processes that set AuthenticatedUserId. 2023-11-06 06:14:16 -08:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Move basebackup code to new directory src/backend/backup 2022-08-10 14:03:09 -04:00
nls.mk Translation updates 2023-11-06 13:16:22 +01:00