Date:

Fri May 26 15:33:21 PDT 1995

Description

Clients and servers with different endian representation cannot talk to each other.

Fix

Apply this patch.

If you apply this patch, you must rebuild libpq, monitor, and psql as well as your backend executable.

The problem was that the startup packets included an integer that was not being converted to a network format and back. With this patch, clients and servers from different architectures can talk to each other as long as they only pass ASCII data.

Any binary data that is transmitted (through a binary portal, for instance) is still in the representation of the sending host.

*** 1.2	1995/03/11 01:00:19
--- libpgtcl/pgconnect.c	1995/05/26 22:22:57
*** 123,129 ****
      msgtype = fe_getauthsvc(conn->errorMessage);
  
      pacBuf = startup2PacketBuf(&startup);
!     pacBuf->msgtype = msgtype;
      status = packetSend(port,pacBuf, sizeof(PacketBuf), BLOCKING);
      
      if (status == STATUS_ERROR)
--- 123,129 ----
      msgtype = fe_getauthsvc(conn->errorMessage);
  
      pacBuf = startup2PacketBuf(&startup);
!     pacBuf->msgtype = htonl(msgtype);
      status = packetSend(port,pacBuf, sizeof(PacketBuf), BLOCKING);
      
      if (status == STATUS_ERROR)
===================================================================
*** 1.6	1995/05/25 01:28:42
--- backend/libpq/pqcomm.c	1995/05/26 22:24:45
*** 539,545 ****
      msgtype = fe_getauthsvc();
  
      pacBuf = StartupInfo2PacketBuf(&startup);
!     pacBuf->msgtype = msgtype;
      status = PacketSend(SendPort, pacBuf, sizeof(PacketBuf), BLOCKING);
      free(pacBuf);
  
--- 539,545 ----
      msgtype = fe_getauthsvc();
  
      pacBuf = StartupInfo2PacketBuf(&startup);
!     pacBuf->msgtype = htonl(msgtype);
      status = PacketSend(SendPort, pacBuf, sizeof(PacketBuf), BLOCKING);
      free(pacBuf);
  
===================================================================
*** 1.3	1994/12/23 17:30:31
--- backend/libpq/pqcomm.h	1995/05/26 22:24:46
*** 68,73 ****
--- 68,76 ----
  #define BLOCKING 	(FALSE)
  #define NON_BLOCKING	(TRUE)
  
+ /* a PacketBuf gets shipped from client to server so be careful
+    of differences in representation.  
+    Be sure to use htonl() and ntohl() on the len and msgtype fields! */
  typedef struct PacketBuf {
      int len;
      MsgType msgtype;

===================================================================
*** 1.15	1995/05/25 17:58:27
--- backend/postmaster/postmaster.c	1995/05/26 22:26:04
*** 508,515 ****
      StartupInfo   	*sp;
      int			pid;
      
-     msgType = port->buf.msgtype;
      sp = PacketBuf2StartupInfo(&port->buf);
  
      (void) strncpy(namebuf, sp->user, USER_NAMESIZE);
      namebuf[USER_NAMESIZE] = '\0';
--- 508,515 ----
      StartupInfo   	*sp;
      int			pid;
      
      sp = PacketBuf2StartupInfo(&port->buf);
+     msgType = ntohl(port->buf.msgtype);
  
      (void) strncpy(namebuf, sp->user, USER_NAMESIZE);
      namebuf[USER_NAMESIZE] = '\0';