summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxcommon/gnuregex.c4
-rw-r--r--src/libs/zbxcomms/comms.c27
-rw-r--r--src/libs/zbxsysinfo/simple/simple.c6
3 files changed, 25 insertions, 12 deletions
diff --git a/src/libs/zbxcommon/gnuregex.c b/src/libs/zbxcommon/gnuregex.c
index d4a89702..b2336a36 100644
--- a/src/libs/zbxcommon/gnuregex.c
+++ b/src/libs/zbxcommon/gnuregex.c
@@ -19,6 +19,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#ifdef DEBUG
+#undef DEBUG
+#endif
+
#if defined(_WIN64) && defined(_MSC_VER)
/* NOTE:
diff --git a/src/libs/zbxcomms/comms.c b/src/libs/zbxcomms/comms.c
index 6fe63320..d4c14cb1 100644
--- a/src/libs/zbxcomms/comms.c
+++ b/src/libs/zbxcomms/comms.c
@@ -538,7 +538,7 @@ int zbx_tcp_recv_ext(zbx_sock_t *s, char **data, unsigned char flags)
int allocated, offset;
zbx_uint64_t expected_len;
-
+
ZBX_TCP_START();
memset(s->buf_stat, 0, sizeof(s->buf_stat));
@@ -546,12 +546,14 @@ int zbx_tcp_recv_ext(zbx_sock_t *s, char **data, unsigned char flags)
read_bytes = 0;
s->buf_type = ZBX_BUF_TYPE_STAT;
-
- nbytes = ZBX_TCP_READ(s->socket, s->buf_stat, ZBX_TCP_HEADER_LEN);
+
+ left = ZBX_TCP_HEADER_LEN;
+ nbytes = ZBX_TCP_READ(s->socket, s->buf_stat, left);
if( ZBX_TCP_HEADER_LEN == nbytes && 0 == strncmp(s->buf_stat, ZBX_TCP_HEADER, ZBX_TCP_HEADER_LEN) )
- {
- nbytes = ZBX_TCP_READ(s->socket, (void *)&expected_len, sizeof(zbx_uint64_t));
+ {
+ left = sizeof(zbx_uint64_t);
+ nbytes = ZBX_TCP_READ(s->socket, (void *)&expected_len, left);
/* The rest was already cleared */
memset(s->buf_stat,0,ZBX_TCP_HEADER_LEN);
@@ -560,10 +562,17 @@ int zbx_tcp_recv_ext(zbx_sock_t *s, char **data, unsigned char flags)
{
read_bytes = nbytes;
expected_len = 16*1024*1024;
- }
-
+ }
+
if( ZBX_TCP_ERROR != nbytes )
{
+ if( flags & ZBX_TCP_READ_UNTIL_CLOSE ) {
+ if(nbytes == 0) return SUCCEED;
+ } else {
+ if(nbytes < left) return SUCCEED;
+ }
+
+
left = sizeof(s->buf_stat) - read_bytes - 1;
/* fill static buffer */
@@ -572,9 +581,9 @@ int zbx_tcp_recv_ext(zbx_sock_t *s, char **data, unsigned char flags)
{
read_bytes += nbytes;
- if( flags & ZBX_TCP_READ_UNTIL_CLOSE ) {
+ if( flags & ZBX_TCP_READ_UNTIL_CLOSE ) {
if(nbytes == 0) break;
- } else {
+ } else {
if(nbytes < left) break;
}
diff --git a/src/libs/zbxsysinfo/simple/simple.c b/src/libs/zbxsysinfo/simple/simple.c
index 48ff72b5..5e584942 100644
--- a/src/libs/zbxsysinfo/simple/simple.c
+++ b/src/libs/zbxsysinfo/simple/simple.c
@@ -113,14 +113,14 @@ static int check_ssh(const char *host, unsigned short port, int *value_int)
send_buf[MAX_BUF_LEN],
*recv_buf,
*ssh_server,
- *ssh_proto;
-
+ *ssh_proto;
+
assert(value_int);
*value_int = 0;
if( SUCCEED == (ret = zbx_tcp_connect(&s, host, port)) )
- {
+ {
if( SUCCEED == (ret = zbx_tcp_recv(&s, &recv_buf)) )
{
if ( 0 == strncmp(recv_buf, "SSH", 3) )