app/procinfo: fix strncpy usage in args parsing
authorRadu Nicolau <radu.nicolau@intel.com>
Tue, 20 Feb 2018 13:52:22 +0000 (13:52 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 27 Mar 2018 22:35:37 +0000 (00:35 +0200)
Replace strncpy with snprintf to avoid overwriting the last
NULL character.

Coverity issue: 143252
Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
Cc: stable@dpdk.org
Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
app/proc-info/main.c

index 2f53e3c..f90c144 100644 (file)
@@ -159,7 +159,7 @@ proc_info_preparse_args(int argc, char **argv)
                                proc_info_usage(prgname);
                                return -1;
                        }
-                       strncpy(host_id, argv[i+1], sizeof(host_id));
+                       snprintf(host_id, sizeof(host_id), "%s", argv[i+1]);
                }
        }