PDA

View Full Version : zbxcomms bug for communication between Solaris and Linux


kempkep
16-08-2007, 05:28
The zabbix comms functions are not transmitting important data in network byte order.

For example the zabbix_sender utility sends the data preceded by a message length stored in a double (64bit) field. Solaris writes this in its big endian format which a Linux server cannot interpret. zabbix _sender times out which fortunately forces and exit at the server end.

This patch converts the message length to a value in network byte order which means any client and server can understand - regadless of endian-ness.

After applying recompile agents and server on all platforms.

--- ./libs/zbxcomms/comms.c-orig 2007-08-16 14:54:49.000000000 +1200
+++ ./libs/zbxcomms/comms.c 2007-08-16 15:00:20.000000000 +1200
@@ -303,6 +303,7 @@ int zbx_tcp_connect(zbx_sock_t *s, c
int zbx_tcp_send_ext(zbx_sock_t *s, const char *data, unsigned char flags)
{
zbx_uint64_t len64;
+ uint32_t len32;

ssize_t i = 0,
written = 0;
@@ -319,9 +320,11 @@ int zbx_tcp_send_ext(zbx_sock_t *s,
}

len64 = (zbx_uint64_t)strlen(data);
+ len32 = (uint32_t)strlen(data);
+ len32 = htonl( len32);

/* Write data length */
- if( ZBX_TCP_ERROR == ZBX_TCP_WRITE(s->socket, (char *) &len64, sizeof(len64)) )
+ if( ZBX_TCP_ERROR == ZBX_TCP_WRITE(s->socket, (char *) &len32, sizeof(len64)) )
{
ZBX_TCP_ERR_START "ZBX_TCP_WRITE() failed [%s]", strerror_from_system(zbx_sock_last_error()) ZBX_TCP_ERR_END;
return FAIL;
@@ -549,6 +552,7 @@ int zbx_tcp_recv_ext(zbx_sock_t *s, char

int allocated, offset;
zbx_uint64_t expected_len;
+ uint32_t explen32;


ZBX_TCP_START();
@@ -569,7 +573,8 @@ int zbx_tcp_recv_ext(zbx_sock_t *s, char
{

left = sizeof(zbx_uint64_t);
- nbytes = ZBX_TCP_READ(s->socket, (void *)&expected_len, left);
+ nbytes = ZBX_TCP_READ(s->socket, (void *)&explen32, left);
+ expected_len= ntohl( explen32);

/* The rest was already cleared */
memset(s->buf_stat,0,ZBX_TCP_HEADER_LEN);

Alexei
19-08-2007, 10:45
Thanks for your report and the patch. The patch is incorrect :)

The problem was fixed yesterday in pre 1.4.2 code. Please download it from www.zabbix.com/developers.php and let me know if it works.

Thank you!