From d040aca671708ce9cb21af87a1389d2230880d91 Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Tue, 18 Jul 2017 02:41:15 +0100 Subject: [PATCH] crypto/scheduler: fix strings not null terminated Coverity issue: 143431 Fixes: 31439ee72b2c ("crypto/scheduler: add API implementations") Cc: stable@dpdk.org Signed-off-by: Pablo de Lara --- drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 14 ++++++++++++++ drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c index 11d0d8110c..df8634addb 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c @@ -461,8 +461,22 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id, sched_ctx = dev->data->dev_private; + if (strlen(scheduler->name) > RTE_CRYPTODEV_NAME_MAX_LEN - 1) { + CS_LOG_ERR("Invalid name %s, should be less than " + "%u bytes.\n", scheduler->name, + RTE_CRYPTODEV_NAME_MAX_LEN); + return -EINVAL; + } strncpy(sched_ctx->name, scheduler->name, RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN); + + if (strlen(scheduler->description) > + RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN - 1) { + CS_LOG_ERR("Invalid description %s, should be less than " + "%u bytes.\n", scheduler->description, + RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN - 1); + return -EINVAL; + } strncpy(sched_ctx->description, scheduler->description, RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN); diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h index e8d3c454bb..df22f2a952 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h @@ -123,6 +123,7 @@ struct rte_cryptodev_scheduler; * - 0 if the scheduler is successfully loaded * - -ENOTSUP if the operation is not supported. * - -EBUSY if device is started. + * - -EINVAL if input values are invalid. */ int rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id, -- 2.20.1