This is an automated email from the ASF dual-hosted git repository. reshke pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 1e1c24ca72c0c4e682a24f04f5e5f12629bbc7f2 Author: Tom Lane <[email protected]> AuthorDate: Mon Aug 10 06:38:23 2026 -0700 Return nulls honestly in aggregate "combine" functions. numeric_combine() and several other state-combining functions for aggregates cheated for the case of both inputs being NULL: they returned a null pointer without bothering to mark it as a SQL NULL. This was harmless in the expected usage where the result would be passed to the same combine function or a related aggregate final function. But it's bad news from a security standpoint, because now that value can be passed to an internal-accepting function even if said function is strict. While a previous patch prevented such queries from being issued, it seems like good defense-in-depth to expend the few additional lines of code needed to do this properly. Comparable functions such as array_agg_combine() already do so. Reported-by: Amy Burnett (OpenAI Codex Security) Author: Tom Lane <[email protected]> Backpatch-through: 14 Security: CVE-2026-14680 --- src/backend/utils/adt/numeric.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index e845b80f553..05f853f3556 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -5061,6 +5061,10 @@ numeric_combine(PG_FUNCTION_ARGS) if (state2 == NULL) { + /* + * NULL state2 is easy, just return state1, which we know is already + * in the agg_context + */ if (state1 == NULL) PG_RETURN_NULL(); PG_RETURN_POINTER(state1); @@ -5157,6 +5161,10 @@ numeric_avg_combine(PG_FUNCTION_ARGS) if (state2 == NULL) { + /* + * NULL state2 is easy, just return state1, which we know is already + * in the agg_context + */ if (state1 == NULL) PG_RETURN_NULL(); PG_RETURN_POINTER(state1); @@ -5665,6 +5673,10 @@ numeric_poly_combine(PG_FUNCTION_ARGS) if (state2 == NULL) { + /* + * NULL state2 is easy, just return state1, which we know is already + * in the agg_context + */ if (state1 == NULL) PG_RETURN_NULL(); PG_RETURN_POINTER(state1); @@ -5880,6 +5892,10 @@ int8_avg_combine(PG_FUNCTION_ARGS) if (state2 == NULL) { + /* + * NULL state2 is easy, just return state1, which we know is already + * in the agg_context + */ if (state1 == NULL) PG_RETURN_NULL(); PG_RETURN_POINTER(state1); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
