char template[DATA_MAX_NAME_LEN];
char value_str[DATA_MAX_NAME_LEN];
- snprintf(template, sizeof(template), "%%{ds:%s}", ds->ds[i].name);
+ const char *format = "%%{ds:%.*s}";
+ snprintf(template, sizeof(template), format,
+ DATA_MAX_NAME_LEN - strlen(format), ds->ds[i].name);
if (ds->ds[i].type != DS_TYPE_GAUGE) {
if ((rates == NULL) && (rates_failed == 0)) {
/* If this is a gauge value, use the current value. */
if (ds->ds[i].type == DS_TYPE_GAUGE)
snprintf(value_str, sizeof(value_str), GAUGE_FORMAT,
- (double)vl->values[i].gauge);
+ (double)vl->values[i].gauge);
/* If it's a counter, try to use the current rate. This may fail, if the
* value has been renamed. */
else if (rates != NULL)