summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1edb3b9)
CC src/table.lo
src/table.c: In function ‘tbl_read_table’:
src/table.c:396:66: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-%s",
^
src/table.c:396:7: note: ‘snprintf’ output 2 or more bytes (assuming 129) into a destination of size 128
snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-%s",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res->instance_prefix, instances_str);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
STATIC_ARRAY_SIZE(instances), "-");
instances_str[sizeof(instances_str) - 1] = '\0';
STATIC_ARRAY_SIZE(instances), "-");
instances_str[sizeof(instances_str) - 1] = '\0';
- vl.type_instance[sizeof(vl.type_instance) - 1] = '\0';
if (res->instance_prefix == NULL)
if (res->instance_prefix == NULL)
- strncpy(vl.type_instance, instances_str, sizeof(vl.type_instance));
+ r = snprintf(vl.type_instance, sizeof(vl.type_instance), "%s",
+ instances_str);
- snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-%s",
- res->instance_prefix, instances_str);
-
- if (vl.type_instance[sizeof(vl.type_instance) - 1] != '\0') {
- vl.type_instance[sizeof(vl.type_instance) - 1] = '\0';
+ r = snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-%s",
+ res->instance_prefix, instances_str);
+ if (r >= sizeof(vl.type_instance))
log_warn("Truncated type instance: %s.", vl.type_instance);
log_warn("Truncated type instance: %s.", vl.type_instance);
}
plugin_dispatch_values(&vl);
}
plugin_dispatch_values(&vl);
for (i = 0; i < tbl->results_num; ++i)
if (tbl_result_dispatch(tbl, tbl->results + i, fields,
for (i = 0; i < tbl->results_num; ++i)
if (tbl_result_dispatch(tbl, tbl->results + i, fields,
- STATIC_ARRAY_SIZE(fields)) != 0) {
+ STATIC_ARRAY_SIZE(fields)) != 0) {
log_err("Failed to dispatch result.");
continue;
}
log_err("Failed to dispatch result.");
continue;
}