examples/ip_pipeline: fix buffer not null terminated
PATCH 1/1 examples/ip_pipeline: fix buffer not null terminated
Coverity issue: 272572
--- examples/ip_pipeline/action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ip_pipeline/action.c +1 -1
@@ -133,7 +133,7 @@ port_in_action_profile_create(const char *name, }/* Node fill in */ -strncpy (profile->name, name,sizeof (profile->name)); +strncpy (profile->name, name,sizeof (profile->name) -1 );memcpy (&profile->params, params,sizeof (*params)); profile->ap = ap;
Signature · 1 line
2.13.6
Quoted 13 lines · Fan Zhang
Coverity issue: 272572
Fixes 719374345cee ("examples/ip_pipeline: add action profile objects")Signed-off-by Fan Zhang <[email protected]>--- examples/ip_pipeline/action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/ip_pipeline/action.c +0
-0
examples/ip_pipeline/action.c port_in_action_profile_create(const char *name, · line 138
Quoted 7 lines
examples/ip_pipeline/action.c +1
-1@@ -133,7 +133,7 @@ port_in_action_profile_create(const char *name, }/* Node fill in */ -strncpy (profile->name, name,sizeof (profile->name)); +strncpy (profile->name, name,sizeof (profile->name) -1 );memcpy (&profile->params, params,sizeof (*params)); profile->ap = ap;
No, this still doesn't null terminate, and is a perfect example of why we should never use strncpy! Use strlcpy instead.
PATCH v2 1/1 examples/ip_pipeline: fix buffer not null terminated
In reply to Fan ZhangCoverity issue: 272572
---
v2:
- use more generic strlcpy approach
examples/ip_pipeline/action.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
examples/ip_pipeline/action.c +3 -1
@@ -6,6 +6,8 @@#include <stdlib.h> #include <string.h> +#include <rte_string_fns.h> +#include "action.h" #include "hash_func.h"
@@ -133,7 +135,7 @@ port_in_action_profile_create(const char *name, }/* Node fill in */ -strncpy (profile->name, name,sizeof (profile->name)); +strlcpy (profile->name, name,sizeof (profile->name));memcpy (&profile->params, params,sizeof (*params)); profile->ap = ap;
Signature · 1 line
2.13.6
Quoted 26 lines · Fan Zhang
Coverity issue: 272572
Fixes 719374345cee ("examples/ip_pipeline: add action profile objects")Signed-off-by Fan Zhang <[email protected]>---
v2:
- use more generic strlcpy approachexamples/ip_pipeline/action.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)examples/ip_pipeline/action.c +2
-0@@ -6,6 +6,8 @@#include <stdlib.h> #include <string.h> +#include <rte_string_fns.h> +#include "action.h" #include "hash_func.h"
examples/ip_pipeline/action.c port_in_action_profile_create(const char *name, · line 141
Quoted 8 lines
examples/ip_pipeline/action.c +1
-1@@ -133,7 +135,7 @@ port_in_action_profile_create(const char *name, }/* Node fill in */ -strncpy (profile->name, name,sizeof (profile->name)); +strlcpy (profile->name, name,sizeof (profile->name));memcpy (&profile->params, params,sizeof (*params)); profile->ap = ap;
Quoted 32 lines
-----Original Message-----
From: Zhang, Roy Fan
Sent: Monday, April 16, 2018 12:03 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Singh, Jasvinder <[email protected]>
Subject: [PATCH] examples/ip_pipeline: fix buffer not null terminatedCoverity issue: 272572
Fixes 719374345cee ("examples/ip_pipeline: add action profile objects")Signed-off-by Fan Zhang <[email protected]>--- examples/ip_pipeline/action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/ip_pipeline/action.c +1
-2@@ -133,7 +133,7 @@ port_in_action_profile_create(const char *name, }/* Node fill in */ -strncpy (profile->name, name,sizeof (profile->name)); +strncpy (profile->name, name,sizeof (profile->name) -1 );memcpy (&profile->params, params,sizeof (*params)); profile->ap = ap; --
Quoted 1 line
2.13.6
Applied to next-pipeline tree, thanks!
Quoted 31 lines · Cristian
Quoted 31 lines
-----Original Message-----
From: Zhang, Roy Fan
Sent: Monday, April 16, 2018 12:03 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Singh, Jasvinder <[email protected]>
Subject: [PATCH] examples/ip_pipeline: fix buffer not null terminatedCoverity issue: 272572
Fixes 719374345cee ("examples/ip_pipeline: add action profile objects")Signed-off-by Fan Zhang <[email protected]>--- examples/ip_pipeline/action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/ip_pipeline/action.c +1
-1@@ -133,7 +133,7 @@ port_in_action_profile_create(const char *name, }/* Node fill in */ -strncpy (profile->name, name,sizeof (profile->name)); +strncpy (profile->name, name,sizeof (profile->name) -1 );memcpy (&profile->params, params,sizeof (*params)); profile->ap = ap;
Quoted 6 lines
Quoted 2 lines
--
2.13.6Applied to next-pipeline tree, thanks!
This is not a correct fix, and the code is still broken. However, I see that you have actually applied the correct v2 patch to the tree, so no big deal. It's probably best to reply to the correct patch confirming it's applied, though.
/Bruce
Quoted 51 lines
-----Original Message-----
From: Richardson, Bruce
Sent: Tuesday, May 8, 2018 8:51 PM
To: Dumitrescu, Cristian <[email protected]>
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Singh, Jasvinder <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] examples/ip_pipeline: fix buffer not null terminatedQuoted 7 lines · Cristian
Quoted 7 lines
-----Original Message-----
From: Zhang, Roy Fan
Sent: Monday, April 16, 2018 12:03 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Singh,Jasvinder
Quoted 6 lines
Quoted 6 lines
<[email protected]>
Subject: [PATCH] examples/ip_pipeline: fix buffer not null terminatedCoverity issue: 272572
Fixes 719374345cee ("examples/ip_pipeline: add action profile objects")Quoted 6 lines
Review
Quoted 6 lines
Signed-off-by Fan Zhang <[email protected]>--- examples/ip_pipeline/action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/examples/ip_pipeline/action.cQuoted 4 lines
examples/ip_pipeline/action.c port_in_action_profile_create(const char
Quoted 4 lines
index
77a04fe19..91011ebe8100644examples/ip_pipeline/action.c +0
-0@@ -133,7 +133,7 @@ port_in_action_profile_create(const char*name,
Quoted 13 lines
Quoted 10 lines
examples/ip_pipeline/action.c +1
-2}/* Node fill in */ -strncpy (profile->name, name,sizeof (profile->name)); +strncpy (profile->name, name,sizeof (profile->name) -1 );memcpy (&profile->params, params,sizeof (*params)); profile->ap = ap; --2.13.6
Quoted 8 lines
Quoted 1 line
Applied to next-pipeline tree, thanks!
This is not a correct fix, and the code is still broken. However, I see that you have actually applied the correct v2 patch to the tree, so no big deal. It's probably best to reply to the correct patch confirming it's applied, though.
/Bruce
Yes, the right patch (v2) was applied, the wrong email was replied.