DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] crypto/scheduler: fix strncpy length
@ 2018-01-26 14:44 Pablo de Lara
  2018-01-26 14:49 ` Richardson, Bruce
  2018-01-29  9:22 ` [dpdk-dev] [PATCH v2] crypto/scheduler: fix strncpy Pablo de Lara
  0 siblings, 2 replies; 6+ messages in thread
From: Pablo de Lara @ 2018-01-26 14:44 UTC (permalink / raw)
  To: roy.fan.zhang; +Cc: dev, Pablo de Lara, stable

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(-)

diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index ccf68a0ee..726f68281 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -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;
-- 
2.14.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] crypto/scheduler: fix strncpy length
  2018-01-26 14:44 [dpdk-dev] [PATCH] crypto/scheduler: fix strncpy length Pablo de Lara
@ 2018-01-26 14:49 ` Richardson, Bruce
  2018-01-29  9:14   ` De Lara Guarch, Pablo
  2018-01-29  9:22 ` [dpdk-dev] [PATCH v2] crypto/scheduler: fix strncpy Pablo de Lara
  1 sibling, 1 reply; 6+ messages in thread
From: Richardson, Bruce @ 2018-01-26 14:49 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, Zhang, Roy Fan; +Cc: dev, De Lara Guarch, Pablo, stable



> -----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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] crypto/scheduler: fix strncpy length
  2018-01-26 14:49 ` Richardson, Bruce
@ 2018-01-29  9:14   ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 6+ messages in thread
From: De Lara Guarch, Pablo @ 2018-01-29  9:14 UTC (permalink / raw)
  To: Richardson, Bruce, Zhang, Roy Fan; +Cc: dev, stable



> -----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 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2] crypto/scheduler: fix strncpy
  2018-01-26 14:44 [dpdk-dev] [PATCH] crypto/scheduler: fix strncpy length Pablo de Lara
  2018-01-26 14:49 ` Richardson, Bruce
@ 2018-01-29  9:22 ` Pablo de Lara
  2018-01-30 12:17   ` Zhang, Roy Fan
  1 sibling, 1 reply; 6+ messages in thread
From: Pablo de Lara @ 2018-01-29  9:22 UTC (permalink / raw)
  To: roy.fan.zhang; +Cc: dev, bruce.richardson, Pablo de Lara, stable

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(-)

diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index ccf68a0ee..140c8b418 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;
-- 
2.14.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] crypto/scheduler: fix strncpy
  2018-01-29  9:22 ` [dpdk-dev] [PATCH v2] crypto/scheduler: fix strncpy Pablo de Lara
@ 2018-01-30 12:17   ` Zhang, Roy Fan
  2018-01-31 18:01     ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Zhang, Roy Fan @ 2018-01-30 12:17 UTC (permalink / raw)
  To: De Lara Guarch, Pablo; +Cc: dev, Richardson, Bruce, stable



> -----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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] crypto/scheduler: fix strncpy
  2018-01-30 12:17   ` Zhang, Roy Fan
@ 2018-01-31 18:01     ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-01-31 18:01 UTC (permalink / raw)
  To: De Lara Guarch, Pablo; +Cc: dev, Zhang, Roy Fan, Richardson, Bruce, stable

> > 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-01-31 18:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26 14:44 [dpdk-dev] [PATCH] crypto/scheduler: fix strncpy length Pablo de Lara
2018-01-26 14:49 ` Richardson, Bruce
2018-01-29  9:14   ` De Lara Guarch, Pablo
2018-01-29  9:22 ` [dpdk-dev] [PATCH v2] crypto/scheduler: fix strncpy Pablo de Lara
2018-01-30 12:17   ` Zhang, Roy Fan
2018-01-31 18:01     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).