From: Florian Forster Date: Tue, 30 Dec 2008 16:13:31 +0000 (+0100) Subject: network plugin: A fix for the buffer problem for version 4.4. X-Git-Tag: collectd-4.4.5~1 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=8eac3d8368d7687e8defbd7f8fa4b96217d6a5f8 network plugin: A fix for the buffer problem for version 4.4. This patch fixes the same problem as 6605ff1a, the insufficient copying of values to the `type' buffer. Thanks again to Bruno Prémont for reporting and debugging this :) Resolves: #37 --- diff --git a/src/network.c b/src/network.c index 0ea51b3b..3a52a43d 100644 --- a/src/network.c +++ b/src/network.c @@ -1395,7 +1395,7 @@ static void network_send_buffer (const char *buffer, int buffer_len) } /* void network_send_buffer */ static int add_to_buffer (char *buffer, int buffer_size, - value_list_t *vl_def, char *type_def, + value_list_t *vl_def, char *type_def, size_t type_def_size, const data_set_t *ds, const value_list_t *vl) { char *buffer_orig = buffer; @@ -1446,7 +1446,7 @@ static int add_to_buffer (char *buffer, int buffer_size, if (write_part_string (&buffer, &buffer_size, TYPE_TYPE, ds->type, strlen (ds->type)) != 0) return (-1); - sstrncpy (type_def, ds->type, sizeof (type_def)); + sstrncpy (type_def, ds->type, type_def_size); } if (strcmp (vl_def->type_instance, vl->type_instance) != 0) @@ -1492,7 +1492,8 @@ static int network_write (const data_set_t *ds, const value_list_t *vl) status = add_to_buffer (send_buffer_ptr, sizeof (send_buffer) - send_buffer_fill, - &send_buffer_vl, send_buffer_type, + &send_buffer_vl, + send_buffer_type, sizeof (send_buffer_type), ds, vl); if (status >= 0) { @@ -1506,7 +1507,8 @@ static int network_write (const data_set_t *ds, const value_list_t *vl) status = add_to_buffer (send_buffer_ptr, sizeof (send_buffer) - send_buffer_fill, - &send_buffer_vl, send_buffer_type, + &send_buffer_vl, + send_buffer_type, sizeof (send_buffer_type), ds, vl); if (status >= 0)