From: Alvaro Herrera Date: Fri, 26 Mar 2021 20:05:10 -0300 Subject: [PATCH v30 6/7] add length check --- src/interfaces/libpq/libpq-trace.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/interfaces/libpq/libpq-trace.c b/src/interfaces/libpq/libpq-trace.c index 06d8d981a3..6c58a578ac 100644 --- a/src/interfaces/libpq/libpq-trace.c +++ b/src/interfaces/libpq/libpq-trace.c @@ -637,6 +637,16 @@ pqTraceOutputMessage(PGconn *conn, const char *message, bool toServer) } fputc('\n', conn->Pfdebug); + + /* + * Verify the printing routine did it right. Note that the one-byte + * message identifier is not included in the length, but our cursor + * does include it. + */ + if (LogCursor - 1 != length) + fprintf(conn->Pfdebug, + "mismatched message length: consumed %d, expected %d\n", + LogCursor - 1, length); } void -- 2.20.1 --qDbXVdCdHGoSgWSk Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v30-0007-Use-libpq_pipeline-to-test-PQtrace.patch"