From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radu Nicolau Subject: [PATCH v3] app/procinfo: fix strncpy count issue Date: Tue, 20 Feb 2018 13:52:22 +0000 Message-ID: <1519134742-22648-1-git-send-email-radu.nicolau@intel.com> References: <1519131621-10053-1-git-send-email-radu.nicolau@intel.com> Cc: john.mcnamara@intel.com, maryam.tahhan@intel.com, reshma.pattan@intel.com, bruce.richardson@intel.com, Radu Nicolau , stable@dpdk.org To: dev@dpdk.org Return-path: In-Reply-To: <1519131621-10053-1-git-send-email-radu.nicolau@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Replace strncpy with snprintf to avoid overwriting the last NULL character. Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id") Coverity issue: 143252 Cc: stable@dpdk.org Signed-off-by: Radu Nicolau --- v3: replaced strncpy with snprintf app/proc_info/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/proc_info/main.c b/app/proc_info/main.c index 2f53e3c..f90c144 100644 --- a/app/proc_info/main.c +++ b/app/proc_info/main.c @@ -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]); } } -- 2.7.5