X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=app%2Fproc_info%2Fmain.c;h=2893bec699115c5bfc3d67713b2fe927072e4333;hb=refs%2Fheads%2Fupstream-17.11-stable;hp=875d91ea3b7387c24eeb309b5cda1a99323bf107;hpb=6e7cbd63706f3435b9d9a2057a37db1da01db9a7;p=deb_dpdk.git diff --git a/app/proc_info/main.c b/app/proc_info/main.c index 875d91ea..2893bec6 100644 --- a/app/proc_info/main.c +++ b/app/proc_info/main.c @@ -517,14 +517,18 @@ nic_xstats_display(uint16_t port_id) if (enable_collectd_format) { char counter_type[MAX_STRING_LEN]; char buf[MAX_STRING_LEN]; + size_t n; collectd_resolve_cnt_type(counter_type, sizeof(counter_type), xstats_names[i].name); - sprintf(buf, "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%" + n = snprintf(buf, MAX_STRING_LEN, + "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%" PRIu64"\n", host_id, port_id, counter_type, xstats_names[i].name, values[i]); - ret = write(stdout_fd, buf, strlen(buf)); + if (n > sizeof(buf) - 1) + n = sizeof(buf) - 1; + ret = write(stdout_fd, buf, n); if (ret < 0) goto err; } else {