[dpdk-dev,v2] crypto/scheduler: fix strncpy
Checks
Commit Message
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(-)
Comments
> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Monday, January 29, 2018 9:22 AM
> To: Zhang, Roy Fan <roy.fan.zhang@intel.com>
> Cc: dev@dpdk.org; Richardson, Bruce <bruce.richardson@intel.com>; De
> Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; stable@dpdk.org
> Subject: [PATCH v2] 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>
> ---
>
> v2:
> - Replaced strncpy with snprintf
Acked-by: Fan Zhang <roy.fan.zhang@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
>
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Applied, thanks
@@ -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;