From patchwork Tue Feb 20 13:52:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radu Nicolau X-Patchwork-Id: 35304 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 73895A49A; Tue, 20 Feb 2018 14:57:40 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 97E812C66; Tue, 20 Feb 2018 14:57:38 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2018 05:57:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,539,1511856000"; d="scan'208";a="36068984" Received: from silpixa00383879.ir.intel.com (HELO silpixa00383879.ger.corp.intel.com) ([10.237.223.127]) by orsmga002.jf.intel.com with ESMTP; 20 Feb 2018 05:57:35 -0800 From: Radu Nicolau To: dev@dpdk.org Cc: john.mcnamara@intel.com, maryam.tahhan@intel.com, reshma.pattan@intel.com, bruce.richardson@intel.com, Radu Nicolau , stable@dpdk.org Date: Tue, 20 Feb 2018 13:52:22 +0000 Message-Id: <1519134742-22648-1-git-send-email-radu.nicolau@intel.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1519131621-10053-1-git-send-email-radu.nicolau@intel.com> References: <1519131621-10053-1-git-send-email-radu.nicolau@intel.com> Subject: [dpdk-dev] [PATCH v3] app/procinfo: fix strncpy count issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list 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 Acked-by: Bruce Richardson --- 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]); } }