From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: roy.fan.zhang@intel.com
Cc: dev@dpdk.org, bruce.richardson@intel.com,
Pablo de Lara <pablo.de.lara.guarch@intel.com>,
stable@dpdk.org
Subject: [dpdk-stable] [PATCH v2] crypto/scheduler: fix strncpy
Date: Mon, 29 Jan 2018 09:22:02 +0000 [thread overview]
Message-ID: <20180129092202.45914-1-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <20180126144428.13154-1-pablo.de.lara.guarch@intel.com>
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 <pablo.de.lara.guarch@intel.com>
---
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
next prev parent reply other threads:[~2018-01-29 9:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-26 14:44 [dpdk-stable] [PATCH] crypto/scheduler: fix strncpy length Pablo de Lara
2018-01-26 14:49 ` [dpdk-stable] [dpdk-dev] " Richardson, Bruce
2018-01-29 9:14 ` De Lara Guarch, Pablo
2018-01-29 9:22 ` Pablo de Lara [this message]
2018-01-30 12:17 ` [dpdk-stable] [PATCH v2] crypto/scheduler: fix strncpy Zhang, Roy Fan
2018-01-31 18:01 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180129092202.45914-1-pablo.de.lara.guarch@intel.com \
--to=pablo.de.lara.guarch@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=roy.fan.zhang@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).