Commit 1ed61b3a authored by Tom Lane's avatar Tom Lane

Fix unportable assumptions about alignment of local char[n] variables.

parent 39ceedf5
......@@ -227,23 +227,29 @@ SOCK_put_string(SocketClass *self, char *string)
int
SOCK_get_int(SocketClass *self, short len)
{
char buf[4];
switch (len)
{
case 2:
SOCK_get_n_char(self, buf, len);
{
unsigned short buf;
SOCK_get_n_char(self, (char *) &buf, len);
if (self->reverse)
return *((unsigned short *) buf);
return buf;
else
return ntohs(*((unsigned short *) buf));
return ntohs(buf);
}
case 4:
SOCK_get_n_char(self, buf, len);
{
unsigned int buf;
SOCK_get_n_char(self, (char *) &buf, len);
if (self->reverse)
return *((unsigned int *) buf);
return buf;
else
return ntohl(*((unsigned int *) buf));
return ntohl(buf);
}
default:
self->errornumber = SOCKET_GET_INT_WRONG_LENGTH;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment