diff options
Diffstat (limited to 'src/plugins/influxdb-writer.c')
-rw-r--r-- | src/plugins/influxdb-writer.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/plugins/influxdb-writer.c b/src/plugins/influxdb-writer.c index 04c94bd..79eb72c 100644 --- a/src/plugins/influxdb-writer.c +++ b/src/plugins/influxdb-writer.c @@ -95,10 +95,11 @@ CURL* make_curl_write_post(afb_api_t apiHandle, const char* url, json_object* me CURL* curl = NULL; size_t lpd = 0, len_write = 0, i = 0; char** post_data; - char write[URL_MAXIMUM_LENGTH] = ""; + char* write = alloca(URL_MAXIMUM_LENGTH); // FIXME: better to use malloc and relloc bigger when needed struct series_t* serie = NULL; json_object* metricsArrayJ = NULL; + write[0] = '\0'; if (json_object_is_type(metricsJ, json_type_array)) { lpd = json_object_array_length(metricsJ); @@ -125,8 +126,8 @@ CURL* make_curl_write_post(afb_api_t apiHandle, const char* url, json_object* me len_write = format_write_args(write, serie); if (len_write > 0) { post_data[i] = malloc(len_write + 1); - strcpy(post_data[i], write); - memset(write, 0, len_write); + strncpy(post_data[i], write, len_write+1); + write[0] = '\0'; } } } |