From 8f5fa18d2573a3239a3f1de3862c91b9ddbe92e3 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Wed, 14 Apr 2010 08:09:47 +0000 Subject: [PATCH] Explicitly detect V2 protocol request and close it with proper msg. --- include/bouncer.h | 1 + src/client.c | 3 +++ src/proto.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/include/bouncer.h b/include/bouncer.h index fdeaa11..44a5123 100644 --- a/include/bouncer.h +++ b/include/bouncer.h @@ -104,6 +104,7 @@ extern int cf_sbuf_len; #define AUTH_CREDS 6 /* type codes for weird pkts */ +#define PKT_STARTUP_V2 0x20000 #define PKT_STARTUP 0x30000 #define PKT_CANCEL 80877102 #define PKT_SSLREQ 80877103 diff --git a/src/client.c b/src/client.c index 613aa54..28d77aa 100644 --- a/src/client.c +++ b/src/client.c @@ -220,6 +220,9 @@ static bool handle_client_startup(PgSocket *client, PktHdr *pkt) return false; } break; + case PKT_STARTUP_V2: + disconnect_client(client, true, "Old V2 protocol not supported"); + return false; case PKT_STARTUP: if (client->pool) { disconnect_client(client, true, "client re-sent startup pkt"); diff --git a/src/proto.c b/src/proto.c index 409e036..2c18c80 100644 --- a/src/proto.c +++ b/src/proto.c @@ -65,6 +65,8 @@ bool get_header(MBuf *data, PktHdr *pkt) type = PKT_SSLREQ; else if ((code >> 16) == 3 && (code & 0xFFFF) < 2) type = PKT_STARTUP; + else if (code == PKT_STARTUP_V2) + type = PKT_STARTUP_V2; else { log_noise("get_header: unknown special pkt: len=%u code=%u", len, code); return false; -- 2.39.5