agora inbox for pgsql-bugs@postgresql.org
help / color / mirror / Atom feedFrom: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Subject: [PATCH v1] Reject too many arguments in CREATE TRIGGER
Date: Wed, 19 Aug 2026 11:40:16 +0900
The number of trigger arguments is stored as an int16, but there was no
check that the number of arguments fits in that type. This could result
in an invalid negative value being stored.
Check that the number of arguments does not exceed INT16_MAX.
---
src/backend/commands/trigger.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index b7881bf4a29..304cc1e7ace 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -897,9 +897,16 @@ CreateTriggerFiringOn(const CreateTrigStmt *stmt, const char *queryString,
{
ListCell *le;
char *args;
- int16 nargs = list_length(stmt->args);
+ int nargs = list_length(stmt->args);
int len = 0;
+ Assert(nargs >= 0);
+ if (nargs > INT16_MAX)
+ ereport(ERROR,
+ errcode(ERRCODE_TOO_MANY_ARGUMENTS),
+ errmsg("triggers cannot have more than %d arguments",
+ INT16_MAX));
+
foreach(le, stmt->args)
{
char *ar = strVal(lfirst(le));
--
2.52.0
----Next_Part(Wed_Aug_19_11_56_36_2026_742)----
view thread (203+ messages) latest in thread
Message-ID: <no-message-id-92474@localhost>
Permalink: ../no-message-id-92474@localhost/
Also on: postgresql.org/message-id/no-message-id-92474@localhost
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: horikyota.ntt@gmail.com
Subject: Re: [PATCH v1] Reject too many arguments in CREATE TRIGGER
In-Reply-To: <no-message-id-92474@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox