[dpdk-dev] crypto/scheduler: fix strncpy length
Checks
Commit Message
The coverity issue was not completely fixed, since strncpy
should be called with max length - 1.
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>
---
drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Friday, January 26, 2018 2:44 PM
> To: Zhang, Roy Fan <roy.fan.zhang@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] crypto/scheduler: fix strncpy length
>
> The coverity issue was not completely fixed, since strncpy should be
> called with max length - 1.
>
> 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>
Use "snprintf", please, to fix these errors sanely without having to worry about
off-by-one issues!
/Bruce
> -----Original Message-----
> From: Richardson, Bruce
> Sent: Friday, January 26, 2018 2:50 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; Zhang, Roy
> Fan <roy.fan.zhang@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; stable@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH] crypto/scheduler: fix strncpy length
>
>
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> > Sent: Friday, January 26, 2018 2:44 PM
> > To: Zhang, Roy Fan <roy.fan.zhang@intel.com>
> > Cc: dev@dpdk.org; De Lara Guarch, Pablo
> > <pablo.de.lara.guarch@intel.com>; stable@dpdk.org
> > Subject: [dpdk-dev] [PATCH] crypto/scheduler: fix strncpy length
> >
> > The coverity issue was not completely fixed, since strncpy should be
> > called with max length - 1.
> >
> > 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>
>
> Use "snprintf", please, to fix these errors sanely without having to worry
> about off-by-one issues!
>
> /Bruce
Thanks for the comment. Will send a v2 shortly.
Pablo
@@ -440,7 +440,7 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
return -EINVAL;
}
strncpy(sched_ctx->name, scheduler->name,
- RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN);
+ RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN - 1);
if (strlen(scheduler->description) >
RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN - 1) {
@@ -450,7 +450,7 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
return -EINVAL;
}
strncpy(sched_ctx->description, scheduler->description,
- RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN);
+ RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN - 1);
/* load scheduler instance operations functions */
sched_ctx->ops.config_queue_pair = scheduler->ops->config_queue_pair;