From ec9c4ee4ad08efe8bef14f161934f9d5373f3c9d Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Mon, 5 Oct 2026 13:39:02 +0900 Subject: [PATCH v2 1/3] Reject v2 protocol startup packet. If v2 frontend connects, raise a FATAL error. Author: Tatsuo Ishii Backpatch-through: master only --- src/protocol/child.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/protocol/child.c b/src/protocol/child.c index 4da5cf12f..ffffbbca5 100644 --- a/src/protocol/child.c +++ b/src/protocol/child.c @@ -5,7 +5,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2025 PgPool Global Development Group + * Copyright (c) 2003-2026 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -158,8 +158,8 @@ bool stop_now = false; static bool connection_pool_initialized = false; /* -* child main loop -*/ + * child main loop + */ void do_child(int *fds) { @@ -620,12 +620,11 @@ backend_cleanup(POOL_CONNECTION *volatile *frontend, POOL_CONNECTION_POOL *volat * Read startup packet * * Read the startup packet and parse the contents. -*/ + */ static StartupPacket * read_startup_packet(POOL_CONNECTION *cp) { StartupPacket *sp; - StartupPacket_v2 *sp2; int protov; int len; char *p; @@ -667,15 +666,10 @@ read_startup_packet(POOL_CONNECTION *cp) switch (sp->major) { - case PROTO_MAJOR_V2: /* V2 */ - sp2 = (StartupPacket_v2 *) (sp->startup_packet); - - sp->database = palloc0(SM_DATABASE + 1); - strncpy(sp->database, sp2->database, SM_DATABASE); - - sp->user = palloc0(SM_USER + 1); - strncpy(sp->user, sp2->user, SM_USER); - + case PROTO_MAJOR_V2: /* V2 protocol is not supported */ + ereport(FATAL, + (errmsg("FATAL: unsupported frontend protocol %u.%u", + sp->major, sp->minor))); break; case PROTO_MAJOR_V3: /* V3 */ -- 2.43.0