1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Fix sanity-check code that mistakenly assumed error and notice messages

could never exceed 30K.  Per report from Andreas Pflug.
This commit is contained in:
Tom Lane
2003-12-28 17:44:05 +00:00
parent 2315548ed7
commit 9c08d8fe56

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.9 2003/08/27 00:33:34 petere Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.9.2.1 2003/12/28 17:44:05 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -35,6 +35,15 @@
#endif #endif
/*
* This macro lists the backend message types that could be "long" (more
* than a couple of kilobytes).
*/
#define VALID_LONG_MESSAGE_TYPE(id) \
((id) == 'T' || (id) == 'D' || (id) == 'd' || (id) == 'V' || \
(id) == 'E' || (id) == 'N' || (id) == 'A')
static void handleSyncLoss(PGconn *conn, char id, int msgLength); static void handleSyncLoss(PGconn *conn, char id, int msgLength);
static int getRowDescriptions(PGconn *conn); static int getRowDescriptions(PGconn *conn);
static int getAnotherTuple(PGconn *conn, int msgLength); static int getAnotherTuple(PGconn *conn, int msgLength);
@ -83,8 +92,7 @@ pqParseInput3(PGconn *conn)
handleSyncLoss(conn, id, msgLength); handleSyncLoss(conn, id, msgLength);
return; return;
} }
if (msgLength > 30000 && if (msgLength > 30000 && !VALID_LONG_MESSAGE_TYPE(id))
!(id == 'T' || id == 'D' || id == 'd'))
{ {
handleSyncLoss(conn, id, msgLength); handleSyncLoss(conn, id, msgLength);
return; return;
@ -1257,8 +1265,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
handleSyncLoss(conn, id, msgLength); handleSyncLoss(conn, id, msgLength);
break; break;
} }
if (msgLength > 30000 && if (msgLength > 30000 && !VALID_LONG_MESSAGE_TYPE(id))
!(id == 'T' || id == 'D' || id == 'd' || id == 'V'))
{ {
handleSyncLoss(conn, id, msgLength); handleSyncLoss(conn, id, msgLength);
break; break;