From 3fba65ca33814bb71aa3c4b5591dffcdab22ac77 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 4 Dec 2007 13:02:53 +0000 Subject: [PATCH] Don't send an empty SSPI negotiation packet at the end of the negotiation. Fixes bug #3750 --- src/interfaces/libpq/fe-auth.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 14124623ed..fd6684bae7 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -618,11 +618,18 @@ pg_SSPI_continue(PGconn *conn) return STATUS_ERROR; } - if (pqPacketSend(conn, 'p', - outbuf.pBuffers[0].pvBuffer, outbuf.pBuffers[0].cbBuffer)) + /* + * If the negotiation is complete, there may be zero bytes to send. The server is + * at this point not expecting any more data, so don't send it. + */ + if (outbuf.pBuffers[0].cbBuffer > 0) { - FreeContextBuffer(outbuf.pBuffers[0].pvBuffer); - return STATUS_ERROR; + if (pqPacketSend(conn, 'p', + outbuf.pBuffers[0].pvBuffer, outbuf.pBuffers[0].cbBuffer)) + { + FreeContextBuffer(outbuf.pBuffers[0].pvBuffer); + return STATUS_ERROR; + } } FreeContextBuffer(outbuf.pBuffers[0].pvBuffer); } -- 2.39.5