X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnetwork.c;h=ac076cccb96dcd5986f406f91cb47747aca285f1;hb=290741f2e6de9e9b467463c1f0c6f031c4036428;hp=6be4ed59521b8b80c2ec9e5220dea961a60fc8d8;hpb=f14bb45d570e0b34bdd3a2a0cadfe414c3dfda40;p=collectd.git diff --git a/src/network.c b/src/network.c index 6be4ed59..ac076ccc 100644 --- a/src/network.c +++ b/src/network.c @@ -36,9 +36,6 @@ #include "network.h" -#if HAVE_PTHREAD_H -# include -#endif #if HAVE_NETDB_H # include #endif @@ -56,7 +53,6 @@ #endif #if HAVE_LIBGCRYPT -# include # if defined __APPLE__ /* default xcode compiler throws warnings even when deprecated functionality * is not used. -Werror breaks the build because of erroneous warnings. @@ -934,7 +930,7 @@ static int parse_part_string (void **ret_buffer, size_t *ret_buffer_len, uint16_t pkg_length; size_t payload_size; - if (output_len <= 0) + if (output_len == 0) return (EINVAL); if (buffer_len < header_size) @@ -1369,7 +1365,7 @@ static int parse_part_encr_aes256 (sockent_t *se, /* {{{ */ warning_has_been_printed = 1; } - *ret_buffer += ph_length; + *ret_buffer = (void *) (((char *) *ret_buffer) + ph_length); *ret_buffer_size -= ph_length; return (0); @@ -1408,7 +1404,7 @@ static int parse_packet (sockent_t *se, /* {{{ */ (void *) buffer, sizeof (pkg_type)); memcpy ((void *) &pkg_length, - (void *) (buffer + sizeof (pkg_type)), + (void *) (((char *) buffer) + sizeof (pkg_type)), sizeof (pkg_length)); pkg_length = ntohs (pkg_length); @@ -1443,6 +1439,7 @@ static int parse_packet (sockent_t *se, /* {{{ */ printed_ignore_warning = 1; } buffer = ((char *) buffer) + pkg_length; + buffer_size -= (size_t) pkg_length; continue; } #endif /* HAVE_LIBGCRYPT */ @@ -1470,6 +1467,7 @@ static int parse_packet (sockent_t *se, /* {{{ */ printed_ignore_warning = 1; } buffer = ((char *) buffer) + pkg_length; + buffer_size -= (size_t) pkg_length; continue; } #endif /* HAVE_LIBGCRYPT */ @@ -1611,6 +1609,7 @@ static int parse_packet (sockent_t *se, /* {{{ */ DEBUG ("network plugin: parse_packet: Unknown part" " type: 0x%04hx", pkg_type); buffer = ((char *) buffer) + pkg_length; + buffer_size -= (size_t) pkg_length; } } /* while (buffer_size > sizeof (part_header_t)) */ @@ -2311,7 +2310,7 @@ static int sockent_server_listen (sockent_t *se) /* {{{ */ freeaddrinfo (ai_list); - if (se->data.server.fd_num <= 0) + if (se->data.server.fd_num == 0) return (-1); return (0); } /* }}} int sockent_server_listen */ @@ -2501,7 +2500,7 @@ static int network_receive (void) /* {{{ */ break; } - ent->data = malloc (*ent->data); + ent->data = malloc (network_config_packet_size); if (ent->data == NULL) { sfree (ent);