You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by re...@apache.org on 2026/06/04 09:05:30 UTC
(cloudberry) 06/22: Unify src/common/'s definitions of MaxAllocSize.
This is an automated email from the ASF dual-hosted git repository.
reshke pushed a commit to branch REL_2_STABLE
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 99eb93fd15c044f148f94acd31f841bd3fcb7902
Author: Tom Lane <tg...@sss.pgh.pa.us>
AuthorDate: Mon May 11 05:13:51 2026 -0700
Unify src/common/'s definitions of MaxAllocSize.
Define MaxAllocSize in src/include/common/fe_memutils.h rather
than having several copies of it in different src/common/*.c files.
This also provides an opportunity to document it better.
Back-patch of commit 11b7de4a7, needed now because assorted security
fixes are adding additional references to MaxAllocSize in frontend
code.
Backpatch-through: 14-17
Security: CVE-2026-6473
---
src/common/psprintf.c | 3 ---
src/common/stringinfo.c | 3 ---
src/include/common/fe_memutils.h | 12 ++++++++++++
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/common/psprintf.c b/src/common/psprintf.c
index 52223c38a45..96caed1dc2d 100644
--- a/src/common/psprintf.c
+++ b/src/common/psprintf.c
@@ -24,9 +24,6 @@
#include "postgres_fe.h"
-/* It's possible we could use a different value for this in frontend code */
-#define MaxAllocSize ((Size) 0x3fffffff) /* 1 gigabyte - 1 */
-
#endif
diff --git a/src/common/stringinfo.c b/src/common/stringinfo.c
index f177516c26f..ec66210adb0 100644
--- a/src/common/stringinfo.c
+++ b/src/common/stringinfo.c
@@ -24,9 +24,6 @@
#include "postgres_fe.h"
-/* It's possible we could use a different value for this in frontend code */
-#define MaxAllocSize ((Size) 0x3fffffff) /* 1 gigabyte - 1 */
-
#endif
#include "lib/stringinfo.h"
diff --git a/src/include/common/fe_memutils.h b/src/include/common/fe_memutils.h
index b706aa195b2..b299077543a 100644
--- a/src/include/common/fe_memutils.h
+++ b/src/include/common/fe_memutils.h
@@ -9,6 +9,18 @@
#ifndef FE_MEMUTILS_H
#define FE_MEMUTILS_H
+/*
+ * Assumed maximum size for allocation requests.
+ *
+ * We don't enforce this, so the actual maximum is the platform's SIZE_MAX.
+ * But it's useful to have it defined in frontend builds, so that common
+ * code can check for oversized requests without having frontend-vs-backend
+ * differences. Also, some code relies on MaxAllocSize being no more than
+ * INT_MAX/2, so rather than setting this to SIZE_MAX, make it the same as
+ * the backend's value.
+ */
+#define MaxAllocSize ((Size) 0x3fffffff) /* 1 gigabyte - 1 */
+
/*
* Flags for pg_malloc_extended and palloc_extended, deliberately named
* the same as the backend flags.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org