DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect
@ 2015-12-11 16:01 Fan Zhang
  2015-12-11 16:27 ` Mcnamara, John
  0 siblings, 1 reply; 5+ messages in thread
From: Fan Zhang @ 2015-12-11 16:01 UTC (permalink / raw)
  To: dev

Coverity issue: 107133
Fixes: eb32fe7c5574 ("examples/ip_pipeline: rework initialization parameters")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
*v2
fixed bug: fix possible buff not null terminated bug

 examples/ip_pipeline/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index bc6d6d9..cabc4f7 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -1068,7 +1068,8 @@ static void app_pipeline_params_get(struct app_params *app,
 	uint32_t i;
 	uint32_t mempool_id;
 
-	strcpy(p_out->name, p_in->name);
+	strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE);
+	p_out->name[PIPELINE_NAME_SIZE - 1] = '\0';
 
 	p_out->socket_id = (int) p_in->socket_id;
 
-- 
2.5.0

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

* Re: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect
  2015-12-11 16:01 [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect Fan Zhang
@ 2015-12-11 16:27 ` Mcnamara, John
  0 siblings, 0 replies; 5+ messages in thread
From: Mcnamara, John @ 2015-12-11 16:27 UTC (permalink / raw)
  To: Zhang, Roy Fan, dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Fan Zhang
> Sent: Friday, December 11, 2015 4:02 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size
> buffer defect
> 
> Coverity issue: 107133
> Fixes: eb32fe7c5574 ("examples/ip_pipeline: rework initialization
> parameters")
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> ---
> *v2
> fixed bug: fix possible buff not null terminated bug
> 
>  examples/ip_pipeline/init.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
> index bc6d6d9..cabc4f7 100644
> --- a/examples/ip_pipeline/init.c
> +++ b/examples/ip_pipeline/init.c
> @@ -1068,7 +1068,8 @@ static void app_pipeline_params_get(struct
> app_params *app,
>  	uint32_t i;
>  	uint32_t mempool_id;
> 
> -	strcpy(p_out->name, p_in->name);
> +	strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE);
> +	p_out->name[PIPELINE_NAME_SIZE - 1] = '\0';

Hi Fan,

The Patch title should have v2 in it but from a code point of view:

Acked-by: John McNamara <john.mcnamara@intel.com>

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

* Re: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect
  2015-12-11 15:37   ` Mcnamara, John
@ 2015-12-11 16:16     ` Richardson, Bruce
  0 siblings, 0 replies; 5+ messages in thread
From: Richardson, Bruce @ 2015-12-11 16:16 UTC (permalink / raw)
  To: Mcnamara, John, Zhang, Roy Fan, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mcnamara, John
> Sent: Friday, December 11, 2015 3:37 PM
> To: Zhang, Roy Fan <roy.fan.zhang@intel.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed
> size buffer defect
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Fan Zhang
> > Sent: Friday, December 11, 2015 11:29 AM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed
> > size buffer defect
> >
> > Coverity issue: 107133
> > Fixes: eb32fe7c5574 ("examples/ip_pipeline: rework initialization
> > parameters")
> >
> > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> > Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> > ---
> >  examples/ip_pipeline/init.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
> > index bc6d6d9..5bcb420 100644
> > --- a/examples/ip_pipeline/init.c
> > +++ b/examples/ip_pipeline/init.c
> > @@ -1068,7 +1068,10 @@ static void app_pipeline_params_get(struct
> > app_params *app,
> >  	uint32_t i;
> >  	uint32_t mempool_id;
> >
> > -	strcpy(p_out->name, p_in->name);
> > +	if (sizeof(p_in->name) > PIPELINE_NAME_SIZE)
> > +		strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE);
> > +	else
> > +		strcpy(p_out->name, p_in->name);
> >
> >  	p_out->socket_id = (int) p_in->socket_id;
> >
> 
> Hi Fan,
> 
> I think there could still be issues here (depending of the size/types of
> p_out->name and p_in->name). Probably better as something like:
> 
>     strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE);
>     p_out->name[PIPELINE_NAME_SIZE -1] = '\0';
> 
> John.
> --

Use snprintf to avoid having to explicitly null terminate, perhaps?
/Bruce

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

* Re: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect
  2015-12-11 11:29 ` [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect Fan Zhang
@ 2015-12-11 15:37   ` Mcnamara, John
  2015-12-11 16:16     ` Richardson, Bruce
  0 siblings, 1 reply; 5+ messages in thread
From: Mcnamara, John @ 2015-12-11 15:37 UTC (permalink / raw)
  To: Zhang, Roy Fan, dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Fan Zhang
> Sent: Friday, December 11, 2015 11:29 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size
> buffer defect
> 
> Coverity issue: 107133
> Fixes: eb32fe7c5574 ("examples/ip_pipeline: rework initialization
> parameters")
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> ---
>  examples/ip_pipeline/init.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
> index bc6d6d9..5bcb420 100644
> --- a/examples/ip_pipeline/init.c
> +++ b/examples/ip_pipeline/init.c
> @@ -1068,7 +1068,10 @@ static void app_pipeline_params_get(struct
> app_params *app,
>  	uint32_t i;
>  	uint32_t mempool_id;
> 
> -	strcpy(p_out->name, p_in->name);
> +	if (sizeof(p_in->name) > PIPELINE_NAME_SIZE)
> +		strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE);
> +	else
> +		strcpy(p_out->name, p_in->name);
> 
>  	p_out->socket_id = (int) p_in->socket_id;
> 

Hi Fan,

I think there could still be issues here (depending of the size/types of p_out->name and p_in->name). Probably better as something like:

    strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE);
    p_out->name[PIPELINE_NAME_SIZE -1] = '\0'; 

John.
-- 

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

* [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect
  2015-12-11 11:29 [dpdk-dev] [PATCH] example/ip_pipeline: fix buffer size warning Fan Zhang
@ 2015-12-11 11:29 ` Fan Zhang
  2015-12-11 15:37   ` Mcnamara, John
  0 siblings, 1 reply; 5+ messages in thread
From: Fan Zhang @ 2015-12-11 11:29 UTC (permalink / raw)
  To: dev

Coverity issue: 107133
Fixes: eb32fe7c5574 ("examples/ip_pipeline: rework initialization parameters")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 examples/ip_pipeline/init.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index bc6d6d9..5bcb420 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -1068,7 +1068,10 @@ static void app_pipeline_params_get(struct app_params *app,
 	uint32_t i;
 	uint32_t mempool_id;
 
-	strcpy(p_out->name, p_in->name);
+	if (sizeof(p_in->name) > PIPELINE_NAME_SIZE)
+		strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE);
+	else
+		strcpy(p_out->name, p_in->name);
 
 	p_out->socket_id = (int) p_in->socket_id;
 
-- 
2.5.0

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

end of thread, other threads:[~2015-12-11 16:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-11 16:01 [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect Fan Zhang
2015-12-11 16:27 ` Mcnamara, John
  -- strict thread matches above, loose matches on Subject: below --
2015-12-11 11:29 [dpdk-dev] [PATCH] example/ip_pipeline: fix buffer size warning Fan Zhang
2015-12-11 11:29 ` [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect Fan Zhang
2015-12-11 15:37   ` Mcnamara, John
2015-12-11 16:16     ` Richardson, Bruce

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