From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 7F3A01B35A; Mon, 29 Jan 2018 10:22:02 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2018 01:22:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,429,1511856000"; d="scan'208";a="169945091" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by orsmga004.jf.intel.com with ESMTP; 29 Jan 2018 01:21:59 -0800 From: Pablo de Lara To: roy.fan.zhang@intel.com Cc: dev@dpdk.org, bruce.richardson@intel.com, Pablo de Lara , stable@dpdk.org Date: Mon, 29 Jan 2018 09:22:02 +0000 Message-Id: <20180129092202.45914-1-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180126144428.13154-1-pablo.de.lara.guarch@intel.com> References: <20180126144428.13154-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2] crypto/scheduler: fix 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: Mon, 29 Jan 2018 09:22:03 -0000 The coverity issue was not completely fixed, since strncpy should not be called with max length. Instead, snprintf is used as a safer option. Coverity issue: 143431 Fixes: d040aca67170 ("crypto/scheduler: fix strings not null terminated") Cc: stable@dpdk.org Signed-off-by: Pablo de Lara --- v2: - Replaced strncpy with snprintf drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c index ccf68a0ee..140c8b418 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c @@ -439,8 +439,8 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id, RTE_CRYPTODEV_NAME_MAX_LEN); return -EINVAL; } - strncpy(sched_ctx->name, scheduler->name, - RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN); + snprintf(sched_ctx->name, sizeof(sched_ctx->name), "%s", + scheduler->name); if (strlen(scheduler->description) > RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN - 1) { @@ -449,8 +449,8 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id, RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN - 1); return -EINVAL; } - strncpy(sched_ctx->description, scheduler->description, - RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN); + snprintf(sched_ctx->description, sizeof(sched_ctx->description), "%s", + scheduler->description); /* load scheduler instance operations functions */ sched_ctx->ops.config_queue_pair = scheduler->ops->config_queue_pair; -- 2.14.3