summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo de Lara <pablo.de.lara.guarch@intel.com>2018-01-29 09:22:02 +0000
committerThomas Monjalon <thomas@monjalon.net>2018-01-31 18:59:39 +0100
commit6af3b03547d7499e8875f7e32effba172140bbfe (patch)
treead7685f8e6e5702d32daf0b267cec9b31f1d0df6
parent200d0e7a708c8a99e1e4b8fe98d56f368d3b6187 (diff)
downloaddpdk-6af3b03547d7499e8875f7e32effba172140bbfe.zip
dpdk-6af3b03547d7499e8875f7e32effba172140bbfe.tar.gz
dpdk-6af3b03547d7499e8875f7e32effba172140bbfe.tar.xz
crypto/scheduler: fix strncpy
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> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
-rw-r--r--drivers/crypto/scheduler/rte_cryptodev_scheduler.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index ccf68a0..140c8b4 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;