From 8eac3d8368d7687e8defbd7f8fa4b96217d6a5f8 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 30 Dec 2008 17:13:31 +0100 Subject: [PATCH] network plugin: A fix for the buffer problem for version 4.4. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/network.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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) -- 2.11.0