Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 024014a

Browse files
committed
Don't send an empty SSPI negotiation packet at the end of the negotiation.
Fixes bug #3750
1 parent 4c12830 commit 024014a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/interfaces/libpq/fe-auth.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.133 2007/11/15 21:14:46 momjian Exp $
10+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.134 2007/12/04 13:02:53 mha Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -618,11 +618,18 @@ pg_SSPI_continue(PGconn *conn)
618618
return STATUS_ERROR;
619619
}
620620

621-
if (pqPacketSend(conn, 'p',
622-
outbuf.pBuffers[0].pvBuffer, outbuf.pBuffers[0].cbBuffer))
621+
/*
622+
* If the negotiation is complete, there may be zero bytes to send. The server is
623+
* at this point not expecting any more data, so don't send it.
624+
*/
625+
if (outbuf.pBuffers[0].cbBuffer > 0)
623626
{
624-
FreeContextBuffer(outbuf.pBuffers[0].pvBuffer);
625-
return STATUS_ERROR;
627+
if (pqPacketSend(conn, 'p',
628+
outbuf.pBuffers[0].pvBuffer, outbuf.pBuffers[0].cbBuffer))
629+
{
630+
FreeContextBuffer(outbuf.pBuffers[0].pvBuffer);
631+
return STATUS_ERROR;
632+
}
626633
}
627634
FreeContextBuffer(outbuf.pBuffers[0].pvBuffer);
628635
}

0 commit comments

Comments
 (0)