aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/arrayfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-11-06 10:38:00 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2023-11-06 10:38:00 -0500
commitd3d1e25097db05edd0e6b44321516e1dce144047 (patch)
tree79ef01067d39cc04527cca3566ffd9c60e8bea08 /src/backend/utils/adt/arrayfuncs.c
parent2c3c5ec4936a6f20354766612ebd650abbb17817 (diff)
downloadpostgresql-d3d1e25097db05edd0e6b44321516e1dce144047.tar.gz
postgresql-d3d1e25097db05edd0e6b44321516e1dce144047.zip
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
Diffstat (limited to 'src/backend/utils/adt/arrayfuncs.c')
0 files changed, 0 insertions, 0 deletions