Index: src/backend/libpq/auth.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/libpq/auth.c,v
retrieving revision 1.84
diff -c -r1.84 auth.c
*** src/backend/libpq/auth.c	27 Aug 2002 15:15:22 -0000	1.84
--- src/backend/libpq/auth.c	27 Aug 2002 16:09:09 -0000
***************
*** 808,813 ****
--- 808,824 ----
  		pfree(buf.data);
  		return STATUS_EOF;
  	}
+ 	/*
+ 	 * We don't actually use the password packet length the frontend
+ 	 * sent us; however, it's a reasonable sanity check to ensure that
+ 	 * we actually read as much data as we expected to.
+ 	 *
+ 	 * The password packet size is the length of the buffer, plus the
+ 	 * size field itself (4 bytes), plus a 1-byte terminator.
+ 	 */
+ 	if (len != (buf.len + 4 + 1))
+ 		elog(LOG, "unexpected password packet size: read %d, expected %d",
+ 			 buf.len + 4 + 1, len);
  
  	/* Do not echo password to logs, for security. */
  	elog(DEBUG5, "received password packet");
Index: src/include/libpq/pqcomm.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/libpq/pqcomm.h,v
retrieving revision 1.67
diff -c -r1.67 pqcomm.h
*** src/include/libpq/pqcomm.h	27 Aug 2002 15:15:23 -0000	1.67
--- src/include/libpq/pqcomm.h	27 Aug 2002 16:09:10 -0000
***************
*** 111,126 ****
   */
  
  /*
!  * FIXME: remove the fixed size limitations on database & user name, use
!  * variable length fields instead. The actual values will still be
!  * limited by NAMEDATALEN, but this will at least allow changing
!  * NAMEDATALEN to increase database & user name limits without changing
!  * the protocol. -neilc, 2002/08/27
   */
   
- /* These should all be of near-unlimited length, perhap 10k */
  #define SM_DATABASE		64
- /* SM_USER should be the same size as the others.  bjm 2002-06-02 */
  #define SM_USER			32
  /* We append database name if db_user_namespace true. */
  #define SM_DATABASE_USER (SM_DATABASE+SM_USER+1) /* +1 for @ */
--- 111,123 ----
   */
  
  /*
!  * FIXME: remove the fixed size limitations on the database name, user
!  * name, and options fields and use a variable length field instead. The
!  * actual limits on database & user name will then be NAMEDATALEN, which
!  * can be changed without changing the FE/BE protocol. -neilc,2002/08/27
   */
   
  #define SM_DATABASE		64
  #define SM_USER			32
  /* We append database name if db_user_namespace true. */
  #define SM_DATABASE_USER (SM_DATABASE+SM_USER+1) /* +1 for @ */
Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.196
diff -c -r1.196 fe-connect.c
*** src/interfaces/libpq/fe-connect.c	27 Aug 2002 15:02:50 -0000	1.196
--- src/interfaces/libpq/fe-connect.c	27 Aug 2002 16:09:10 -0000
***************
*** 1132,1138 ****
  		/*
  		 * If connecting timeout is set, calculate remain time.
  		 */
! 		if (NULL != rp)
  		{
  			if (gettimeofday(&finish_time, NULL) == -1)
  			{
--- 1132,1138 ----
  		/*
  		 * If connecting timeout is set, calculate remain time.
  		 */
! 		if (rp != NULL)
  		{
  			if (gettimeofday(&finish_time, NULL) == -1)
  			{
***************
*** 1152,1159 ****
  			remains.tv_sec -= finish_time.tv_sec - start_time.tv_sec;
  		}
  	}
!       conn->status = CONNECTION_BAD;
!       return 0;
  }
  
  /* ----------------
--- 1152,1159 ----
  			remains.tv_sec -= finish_time.tv_sec - start_time.tv_sec;
  		}
  	}
! 	conn->status = CONNECTION_BAD;
! 	return 0;
  }
  
  /* ----------------
***************
*** 1162,1168 ****
   * Poll an asynchronous connection.
   *
   * Returns a PostgresPollingStatusType.
!  * Before calling this function, use select(2) to determine when data arrive.
   *
   * You must call PQfinish whether or not this fails.
   *
--- 1162,1169 ----
   * Poll an asynchronous connection.
   *
   * Returns a PostgresPollingStatusType.
!  * Before calling this function, use select(2) to determine when data
!  * has arrived..
   *
   * You must call PQfinish whether or not this fails.
   *
***************
*** 1356,1362 ****
  				{
  					if (pqGets(&conn->errorMessage, conn))
  					{
! 						/* We'll come back when there are more data */
  						return PGRES_POLLING_READING;
  					}
  					/* OK, we read the message; mark data consumed */
--- 1357,1363 ----
  				{
  					if (pqGets(&conn->errorMessage, conn))
  					{
! 						/* We'll come back when there is more data */
  						return PGRES_POLLING_READING;
  					}
  					/* OK, we read the message; mark data consumed */
