From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id AC4B71B0F9; Mon, 4 Feb 2019 08:16:36 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Feb 2019 23:16:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,559,1539673200"; d="scan'208";a="123719596" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 03 Feb 2019 23:16:34 -0800 Received: from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com [10.102.246.100]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x147GXJ5018280; Mon, 4 Feb 2019 07:16:33 GMT Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x147Fwo1002711; Mon, 4 Feb 2019 07:15:58 GMT Received: (from ppoornix@localhost) by wgcvswdev001.ir.intel.com with œ id x147FwSO002707; Mon, 4 Feb 2019 07:15:58 GMT From: Pallantla Poornima To: dev@dpdk.org Cc: reshma.pattan@intel.com, amr.mokhtar@intel.com, Pallantla Poornima , stable@dpdk.org Date: Mon, 4 Feb 2019 07:15:54 +0000 Message-Id: <1549264554-2501-1-git-send-email-pallantlax.poornima@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: Subject: [dpdk-dev] [PATCH] app/testbbdev: fix sprintf with snprintf 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: Mon, 04 Feb 2019 07:16:37 -0000 sprintf function is not secure as it doesn't check the length of string. More secure function snprintf is used. Fixes: f714a18885 ("app/testbbdev: add test application for bbdev") Cc: stable@dpdk.org Signed-off-by: Pallantla Poornima --- app/test-bbdev/test_bbdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/test-bbdev/test_bbdev.c b/app/test-bbdev/test_bbdev.c index a914817bc..b9fc750d3 100644 --- a/app/test-bbdev/test_bbdev.c +++ b/app/test-bbdev/test_bbdev.c @@ -788,14 +788,14 @@ test_bbdev_driver_init(void) /* Initialize the maximum amount of devices */ do { - sprintf(name_tmp, "%s%i", "name_", num_devs); + snprintf(name_tmp, sizeof(name_tmp), "%s%i", "name_", num_devs); dev2 = rte_bbdev_allocate(name_tmp); TEST_ASSERT(dev2 != NULL, "Failed to initialize bbdev driver"); ++num_devs; } while (num_devs < (RTE_BBDEV_MAX_DEVS - 1)); - sprintf(name_tmp, "%s%i", "name_", num_devs); + snprintf(name_tmp, sizeof(name_tmp), "%s%i", "name_", num_devs); dev2 = rte_bbdev_allocate(name_tmp); TEST_ASSERT(dev2 == NULL, "Failed to initialize bbdev driver number %d " "more drivers than RTE_BBDEV_MAX_DEVS: %d ", num_devs, @@ -804,7 +804,7 @@ test_bbdev_driver_init(void) num_devs--; while (num_devs >= num_devs_tmp) { - sprintf(name_tmp, "%s%i", "name_", num_devs); + snprintf(name_tmp, sizeof(name_tmp), "%s%i", "name_", num_devs); dev2 = rte_bbdev_get_named_dev(name_tmp); TEST_ASSERT_SUCCESS(rte_bbdev_release(dev2), "Failed to uninitialize bbdev driver %s ", @@ -825,7 +825,7 @@ test_bbdev_driver_init(void) TEST_ASSERT_FAIL(rte_bbdev_release(NULL), "Failed to uninitialize bbdev driver with NULL bbdev"); - sprintf(name_tmp, "%s", "invalid_name"); + snprintf(name_tmp, sizeof(name_tmp), "%s", "invalid_name"); dev2 = rte_bbdev_get_named_dev(name_tmp); TEST_ASSERT_FAIL(rte_bbdev_release(dev2), "Failed to uninitialize bbdev driver with invalid name"); -- 2.17.2