summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo de Lara <pablo.de.lara.guarch@intel.com>2017-07-18 02:41:15 +0100
committerYuanhan Liu <yliu@fridaylinux.org>2017-08-29 14:50:28 +0800
commite1ee9cb30063b9c0075b8c2ca17392fbf22c0f38 (patch)
treebe4908701a025c4a5beac5f4db3d649a35fc6cfb
parent28c88cd10670c7ac90b90ee291b682232252f124 (diff)
downloaddpdk-stable-e1ee9cb30063b9c0075b8c2ca17392fbf22c0f38.zip
dpdk-stable-e1ee9cb30063b9c0075b8c2ca17392fbf22c0f38.tar.gz
dpdk-stable-e1ee9cb30063b9c0075b8c2ca17392fbf22c0f38.tar.xz
crypto/scheduler: fix strings not null terminated
[ upstream commit d040aca671708ce9cb21af87a1389d2230880d91 ] Coverity issue: 143431 Fixes: 31439ee72b2c ("crypto/scheduler: add API implementations") Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
-rw-r--r--drivers/crypto/scheduler/rte_cryptodev_scheduler.c14
-rw-r--r--drivers/crypto/scheduler/rte_cryptodev_scheduler.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 319dcf0..88f8fc0 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -467,8 +467,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 2ba6e47..b250a58 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h
@@ -116,6 +116,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,