examples/ip_pipeline: fix buffer not null terminated
PATCH 1/1 examples/ip_pipeline: fix buffer not null terminated
The destination string may not have a null termination if the source string's length is equal to the sizeof(pipeline->name).
Fix by replacing strncpy with strlcpy that guarantees NULL-termination.
Coverty issue: 272606
--- examples/ip_pipeline/pipeline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ip_pipeline/pipeline.c +1 -1
@@ -129,7 +129,7 @@ pipeline_create(const char *name, struct pipeline_params *params) }/* Node fill in */ -strncpy (pipeline->name, name,sizeof (pipeline->name)); +strlcpy (pipeline->name, name,sizeof (pipeline->name)); pipeline->p = p; pipeline->n_ports_in =0 ; pipeline->n_ports_out =0 ;
Signature · 1 line
2.9.3
Quoted 9 lines · Jasvinder Singh
The destination string may not have a null termination if the source string's length is equal to the
sizeof(pipeline->name).Fix by replacing strncpy with strlcpy that guarantees NULL-termination.
Coverty issue: 272606
Fixes d75c371e9b46 ("examples/ip_pipeline: add pipeline object")Signed-off-by Jasvinder Singh <[email protected]>
Does this need an include of rte_string_fns.h?
In terms of the change itself:
Quoted 20 lines
--- examples/ip_pipeline/pipeline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/ip_pipeline/pipeline.c +1
-1@@ -129,7 +129,7 @@ pipeline_create(const char *name, struct pipeline_params *params) }/* Node fill in */ -strncpy (pipeline->name, name,sizeof (pipeline->name)); +strlcpy (pipeline->name, name,sizeof (pipeline->name)); pipeline->p = p; pipeline->n_ports_in =0 ; pipeline->n_ports_out =0 ;Signature · 1 line
2.9.3
Quoted 17 lines
-----Original Message-----
From: Richardson, Bruce
Sent: Tuesday, April 17, 2018 4:01 PM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; Dumitrescu, Cristian <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] examples/ip_pipeline: fix buffer not null terminatedQuoted 8 lines · Jasvinder Singh
The destination string may not have a null termination if the source string's length is equal to the
sizeof(pipeline->name).Fix by replacing strncpy with strlcpy that guarantees NULL-termination.
Coverty issue: 272606
Fixes d75c371e9b46 ("examples/ip_pipeline: add pipeline object")
Quoted 8 lines
Quoted 1 line
Signed-off-by Jasvinder Singh <[email protected]>Does this need an include of
rte_string_fns.h?In terms of the change itself:
Acked-by Bruce Richardson <[email protected]>
It got reference of rte_string_fns.h through other header files there. So build was ok, but I will send v2 with explicit include. Thanks.
PATCH v2 1/1 examples/ip_pipeline: fix buffer not null terminated
In reply to Jasvinder SinghThe destination string may not have a null termination if the source string's length is equal to the sizeof(pipeline->name).
Fix by replacing strncpy with strlcpy that guarantees NULL-termination.
Coverty issue: 272606
--- examples/ip_pipeline/pipeline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
examples/ip_pipeline/pipeline.c +2 -1
@@ -9,6 +9,7 @@#include <rte_ip.h> #include <rte_tcp.h> +#include <rte_string_fns.h> #include <rte_port_ethdev.h> #ifdef RTE_LIBRTE_KNI #include <rte_port_kni.h>
@@ -129,7 +130,7 @@ pipeline_create(const char *name, struct pipeline_params *params) }/* Node fill in */ -strncpy (pipeline->name, name,sizeof (pipeline->name)); +strlcpy (pipeline->name, name,sizeof (pipeline->name)); pipeline->p = p; pipeline->n_ports_in =0 ; pipeline->n_ports_out =0 ;
Signature · 1 line
2.9.3
Quoted 46 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Tuesday, April 17, 2018 5:40 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH v2] examples/ip_pipeline: fix buffer not null terminatedThe destination string may not have a null termination if the source string's length is equal to the
sizeof(pipeline->name).Fix by replacing strncpy with strlcpy that guarantees NULL-termination.
Coverty issue: 272606
Fixes d75c371e9b46 ("examples/ip_pipeline: add pipeline object")Signed-off-by Jasvinder Singh <[email protected]>Acked-by Bruce Richardson <[email protected]>--- examples/ip_pipeline/pipeline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)examples/ip_pipeline/pipeline.c +2
-1@@ -9,6 +9,7 @@#include <rte_ip.h> #include <rte_tcp.h> +#include <rte_string_fns.h> #include <rte_port_ethdev.h> #ifdef RTE_LIBRTE_KNI #include <rte_port_kni.h> @@ -129,7 +130,7 @@ pipeline_create(const char *name, struct pipeline_params *params) }/* Node fill in */ -strncpy (pipeline->name, name,sizeof (pipeline->name)); +strlcpy (pipeline->name, name,sizeof (pipeline->name)); pipeline->p = p; pipeline->n_ports_in =0 ;
Quoted 3 lines
pipeline->n_ports_out= 0;
--
2.9.3
Applied to next-pipeline tree, thanks!