aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_param.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2024-07-02 09:24:04 +0200
committerPeter Eisentraut <peter@eisentraut.org>2024-07-02 09:29:26 +0200
commit9c2e660b07fc16bdd79c25047cce6cde2acb3f37 (patch)
tree27f142eef907af6f054d62316127432a9941f016 /src/backend/parser/parse_param.c
parentd35cd061998434747c0d1c0f6f2aa1f736f0edb4 (diff)
downloadpostgresql-9c2e660b07fc16bdd79c25047cce6cde2acb3f37.tar.gz
postgresql-9c2e660b07fc16bdd79c25047cce6cde2acb3f37.zip
Limit max parameter number with MaxAllocSize
MaxAllocSize puts an upper bound on the largest possible parameter number ($268435455). Use that limit instead of INT_MAX to report that no parameters exist beyond that point instead of reporting an error about the maximum allocation size being exceeded. Author: Erik Wienhold <ewie@ewie.name> Discussion: https://www.postgresql.org/message-id/flat/5d216d1c-91f6-4cbe-95e2-b4cbd930520c@ewie.name
Diffstat (limited to 'src/backend/parser/parse_param.c')
-rw-r--r--src/backend/parser/parse_param.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/parser/parse_param.c b/src/backend/parser/parse_param.c
index dbf1a7dff08..b617591ef68 100644
--- a/src/backend/parser/parse_param.c
+++ b/src/backend/parser/parse_param.c
@@ -31,6 +31,7 @@
#include "parser/parse_param.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
+#include "utils/memutils.h"
typedef struct FixedParamState
@@ -136,7 +137,7 @@ variable_paramref_hook(ParseState *pstate, ParamRef *pref)
Param *param;
/* Check parameter number is in range */
- if (paramno <= 0 || paramno > INT_MAX / sizeof(Oid))
+ if (paramno <= 0 || paramno > MaxAllocSize / sizeof(Oid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PARAMETER),
errmsg("there is no parameter $%d", paramno),