[dpdk-dev] example/ip_pipeline: fix copy into fixed size buffer defect

Message ID 1449849702-30365-1-git-send-email-roy.fan.zhang@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Fan Zhang Dec. 11, 2015, 4:01 p.m. UTC
  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(-)
  

Comments

John McNamara Dec. 11, 2015, 4:27 p.m. UTC | #1
> -----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>
  

Patch

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;