Skip to content

Commit d167fb1

Browse files
committed
Fix sanity-check code that mistakenly assumed error and notice messages
could never exceed 30K. Per report from Andreas Pflug.
1 parent 36c9a01 commit d167fb1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/interfaces/libpq/fe-protocol3.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.10 2003/11/29 19:52:12 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.11 2003/12/28 17:43:57 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -35,6 +35,15 @@
3535
#endif
3636

3737

38+
/*
39+
* This macro lists the backend message types that could be "long" (more
40+
* than a couple of kilobytes).
41+
*/
42+
#define VALID_LONG_MESSAGE_TYPE(id) \
43+
((id) == 'T' || (id) == 'D' || (id) == 'd' || (id) == 'V' || \
44+
(id) == 'E' || (id) == 'N' || (id) == 'A')
45+
46+
3847
static void handleSyncLoss(PGconn *conn, char id, int msgLength);
3948
static int getRowDescriptions(PGconn *conn);
4049
static int getAnotherTuple(PGconn *conn, int msgLength);
@@ -83,8 +92,7 @@ pqParseInput3(PGconn *conn)
8392
handleSyncLoss(conn, id, msgLength);
8493
return;
8594
}
86-
if (msgLength > 30000 &&
87-
!(id == 'T' || id == 'D' || id == 'd'))
95+
if (msgLength > 30000 && !VALID_LONG_MESSAGE_TYPE(id))
8896
{
8997
handleSyncLoss(conn, id, msgLength);
9098
return;
@@ -1257,8 +1265,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
12571265
handleSyncLoss(conn, id, msgLength);
12581266
break;
12591267
}
1260-
if (msgLength > 30000 &&
1261-
!(id == 'T' || id == 'D' || id == 'd' || id == 'V'))
1268+
if (msgLength > 30000 && !VALID_LONG_MESSAGE_TYPE(id))
12621269
{
12631270
handleSyncLoss(conn, id, msgLength);
12641271
break;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy