From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 641C31B792 for ; Wed, 31 Jan 2018 13:40:45 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2018 04:40:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,440,1511856000"; d="scan'208";a="15844357" Received: from silpixa00391537.ir.intel.com (HELO silpixa00391537.ger.corp.intel.com) ([10.237.222.189]) by fmsmga002.fm.intel.com with ESMTP; 31 Jan 2018 04:40:43 -0800 From: Amr Mokhtar To: dev@dpdk.org Cc: Amr Mokhtar Date: Wed, 31 Jan 2018 12:40:40 +0000 Message-Id: <1517402440-129255-1-git-send-email-amr.mokhtar@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] app/testbbdev: fix buffer null termination due to strncpy 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: , X-List-Received-Date: Wed, 31 Jan 2018 12:40:45 -0000 use snprintf instead of strncpy to ensure null termination when copying test_vector_filename from cmd arguments. Coverity issue: 257001 Fixes: f714a18885a6 ("app/testbbdev: add test application for bbdev") Signed-off-by: Amr Mokhtar --- app/test-bbdev/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/test-bbdev/main.c b/app/test-bbdev/main.c index 3f542a8..41b54bb 100644 --- a/app/test-bbdev/main.c +++ b/app/test-bbdev/main.c @@ -226,8 +226,9 @@ parse_args(int argc, char **argv, struct test_params *tp) TEST_ASSERT(strlen(optarg) > 0, "Config file name is null"); - strncpy(tp->test_vector_filename, optarg, - sizeof(tp->test_vector_filename)); + snprintf(tp->test_vector_filename, + sizeof(tp->test_vector_filename), + "%s", optarg); break; case 'l': TEST_ASSERT(strlen(optarg) > 0, -- 2.7.4