From patchwork Mon Feb 4 07:18:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Poornima, PallantlaX" X-Patchwork-Id: 50125 X-Patchwork-Delegate: jerinj@marvell.com 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 DFAD41B130; Mon, 4 Feb 2019 08:18:45 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 5A5211B0F9; Mon, 4 Feb 2019 08:18:43 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Feb 2019 23:18:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,559,1539673200"; d="scan'208";a="135658846" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 03 Feb 2019 23:18:40 -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 x147Ie4m018585; Mon, 4 Feb 2019 07:18:40 GMT Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x147I4mg003268; Mon, 4 Feb 2019 07:18:04 GMT Received: (from ppoornix@localhost) by wgcvswdev001.ir.intel.com with ? id x147I4nZ003264; Mon, 4 Feb 2019 07:18:04 GMT From: Pallantla Poornima To: dev@dpdk.org Cc: reshma.pattan@intel.com, liang.j.ma@intel.com, peter.mccarthy@intel.com, Pallantla Poornima , stable@dpdk.org Date: Mon, 4 Feb 2019 07:18:02 +0000 Message-Id: <1549264682-2979-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] event/opdl: 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" sprintf function is not secure as it doesn't check the length of string. More secure function snprintf is used. Fixes: 3c7f3dcfb0 ("event/opdl: add PMD main body and helper function") Cc: stable@dpdk.org Signed-off-by: Pallantla Poornima --- drivers/event/opdl/opdl_evdev.c | 7 ++++--- drivers/event/opdl/opdl_evdev_xstats.c | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c index a4f0bc8b6..d2d2be44b 100644 --- a/drivers/event/opdl/opdl_evdev.c +++ b/drivers/event/opdl/opdl_evdev.c @@ -422,16 +422,17 @@ opdl_dump(struct rte_eventdev *dev, FILE *f) else p_type = "????"; - sprintf(queue_id, "%02u", port->external_qid); + snprintf(queue_id, sizeof(queue_id), "%02u", + port->external_qid); if (port->p_type == OPDL_REGULAR_PORT || port->p_type == OPDL_ASYNC_PORT) - sprintf(total_cyc, + snprintf(total_cyc, sizeof(total_cyc), " %'16"PRIu64"", (cpg != 0 ? port->port_stat[total_cycles] / cpg : 0)); else - sprintf(total_cyc, + snprintf(total_cyc, sizeof(total_cyc), " ----"); fprintf(f, "%4s %10u %8u %9s %'16"PRIu64" %'16"PRIu64" %s " diff --git a/drivers/event/opdl/opdl_evdev_xstats.c b/drivers/event/opdl/opdl_evdev_xstats.c index 0e6c6bd5e..27b3d8802 100644 --- a/drivers/event/opdl/opdl_evdev_xstats.c +++ b/drivers/event/opdl/opdl_evdev_xstats.c @@ -32,10 +32,9 @@ opdl_xstats_init(struct rte_eventdev *dev) uint32_t index = (i * max_num_port_xstat) + j; /* Name */ - sprintf(device->port_xstat[index].stat.name, - "port_%02u_%s", - i, - port_xstat_str[j]); + snprintf(device->port_xstat[index].stat.name, + sizeof(device->port_xstat[index].stat.name), + "port_%02u_%s", i, port_xstat_str[j]); /* ID */ device->port_xstat[index].id = index;