Skip to contentSkip to conversation

example/ip_pipeline: fix buffer size warning

PATCH In review Fan Zhang 4 participants 14 messages Dec 11, 2015 – Dec 13, 2015

lore
Share & tools
lore

Fan Zhang

author
#0 lore raw

PATCH 1/1 example/ip_pipeline: fix buffer size warning

Coverity issue: 107102

Fixes 7f64b9c004aa ("examples/ip_pipeline: rework config file syntax")
---
 examples/ip_pipeline/config_parse_tm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ip_pipeline/config_parse_tm.c +1 -1
index cdebbdc..3932247 100644
@@ -349,7 +349,7 @@ tm_cfgfile_load_sched_subport(
 					char *tokens[2] = {NULL, NULL};
 					int n_tokens;
 					int begin, end;
-					char name[CFG_NAME_LEN];
+					char name[CFG_NAME_LEN + 1];
 
 					profile = atoi(entries[j].value);
 					strncpy(name,
Signature · 1 line
2.5.0
author
#1 lore raw

PATCH 1/1 example/ip_pipeline: fix copy into fixed size buffer defect

Coverity issue: 107133

Fixes eb32fe7c5574 ("examples/ip_pipeline: rework initialization parameters")
---
 examples/ip_pipeline/init.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
examples/ip_pipeline/init.c +4 -1
index bc6d6d9..5bcb420 100644
@@ -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;
 
Signature · 1 line
2.5.0
author
#4 lore raw

PATCH 1/1 example/ip_pipeline: fix copy-paste error

In reply to Fan Zhang

Coverity issue: 107104

Fixes 7f64b9c004aa ("examples/ip_pipeline: rework config file syntax")
---
 examples/ip_pipeline/config_parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ip_pipeline/config_parse.c +1 -1
index 67e58c9..dbeb3a9 100644
@@ -2398,7 +2398,7 @@ save_pipeline_params(struct app_params *app, FILE *f)
 		}
 
 		/* msgq_out */
-		if (p->n_msgq_in) {
+		if (p->n_msgq_out) {
 			uint32_t j;
 
 			fprintf(f, "msgq_out =");
Signature · 1 line
2.5.0
author
#6 lore raw

PATCH 1/1 example/ip_pipeline: fix logically deadnode defect

In reply to Fan Zhang

Coverity issue: 107109

Fixes 7122d30131ad ("examples/ip_pipeline: rework flow classification pipeline")
---
 examples/ip_pipeline/pipeline/pipeline_flow_classification.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ip_pipeline/pipeline/pipeline_flow_classification.c +1 -1
index 76a152f..1921574 100644
@@ -448,7 +448,7 @@ app_pipeline_fc_add_bulk(struct app_params *app,
 	flow_rsp = rte_malloc(NULL,
 		n_keys * sizeof(struct pipeline_fc_add_bulk_flow_rsp),
 		RTE_CACHE_LINE_SIZE);
-	if (flow_req == NULL) {
+	if (flow_rsp == NULL) {
 		rte_free(flow_req);
 		rte_free(new_flow);
 		rte_free(signature);
Signature · 1 line
2.5.0
author
#8 lore raw

PATCH 1/1 example/ip_pipeline: fix overrunning byffer defect

In reply to Fan Zhang

Coverity issue: 107127

Fixes 7f64b9c004aa ("examples/ip_pipeline: rework config file syntax")
---
 examples/ip_pipeline/config_parse_tm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ip_pipeline/config_parse_tm.c +1 -1
index cdebbdc..84702b0 100644
@@ -399,7 +399,7 @@ tm_cfgfile_load(struct app_pktq_tm_params *tm)
 
 	memset(tm->sched_subport_params, 0, sizeof(tm->sched_subport_params));
 	memset(tm->sched_pipe_profiles, 0, sizeof(tm->sched_pipe_profiles));
-	memset(&tm->sched_port_params, 0, sizeof(tm->sched_pipe_profiles));
+	memset(&tm->sched_port_params, 0, sizeof(tm->sched_port_params));
 	for (i = 0; i < APP_MAX_SCHED_SUBPORTS * APP_MAX_SCHED_PIPES; i++)
 		tm->sched_pipe_to_profile[i] = -1;
 
Signature · 1 line
2.5.0
author
#10 lore raw

PATCH 1/1 example/ip_pipeline: fix value overwrite

In reply to Fan Zhang

Coverity issue: 107136

Fixes 7f64b9c004aa ("examples/ip_pipeline: rework config file syntax")
---
 examples/ip_pipeline/config_parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
examples/ip_pipeline/config_parse.c +2 -2
index 67e58c9..4e194d6 100644
@@ -1631,8 +1631,8 @@ parse_tm(struct app_params *app,
 			param->file_name = strdup(ent->value);
 			if (param->file_name == NULL)
 				ret = -EINVAL;
-
-			ret = 0;
+			else
+				ret = 0;
 		} else if (strcmp(ent->name, "burst_read") == 0)
 			ret = parser_read_uint32(&param->burst_read,
 				ent->value);
Signature · 1 line
2.5.0
Acked-by on v1 1/1
#12 lore raw
In reply to Fan Zhang
Quoted 11 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Fan Zhang
Sent: Friday, December 11, 2015 11:29 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH] example/ip_pipeline: fix buffer size warning

Coverity issue: 107102

Fixes 7f64b9c004aa ("examples/ip_pipeline: rework config file syntax")
Acked-by on v1 1/1
#5 lore raw

Re: [PATCH] example/ip_pipeline: fix copy-paste error

In reply to Fan Zhang
Quoted 11 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Fan Zhang
Sent: Friday, December 11, 2015 11:29 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy-paste error

Coverity issue: 107104

Fixes 7f64b9c004aa ("examples/ip_pipeline: rework config file syntax")
Acked-by on v1 1/1
#7 lore raw

Re: [PATCH] example/ip_pipeline: fix logically deadnode defect

In reply to Fan Zhang
Quoted 7 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Fan Zhang
Sent: Friday, December 11, 2015 11:29 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH] example/ip_pipeline: fix logically deadnode defect

Quoted 6 lines

Coverity issue: 107109

Fixes 7122d30131ad ("examples/ip_pipeline: rework flow classification

pipeline")

Acked-by on v1 1/1
#9 lore raw

Re: [PATCH] example/ip_pipeline: fix overrunning byffer defect

In reply to Fan Zhang
Quoted 7 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Fan Zhang
Sent: Friday, December 11, 2015 11:29 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH] example/ip_pipeline: fix overrunning byffer defect

Quoted 5 lines

Coverity issue: 107127

Fixes 7f64b9c004aa ("examples/ip_pipeline: rework config file syntax")

Thanks for updating the Coverity Triage for these issues.

#2 lore raw

Re: [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect

In reply to Fan Zhang
Quoted 24 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Fan Zhang
Sent: Friday, December 11, 2015 11:29 AM
To: [email protected]
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")

---
 examples/ip_pipeline/init.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
examples/ip_pipeline/init.c +0 -0
index bc6d6d9..5bcb420 100644
@@ -1068,7 +1068,10 @@ static void app_pipeline_params_get(struct
 app_params *app,

examples/ip_pipeline/init.c static void app_pipeline_params_get(struct · line 1077

Quoted 10 lines
examples/ip_pipeline/init.c +4 -1
 	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.

Acked-by on v1 1/1
#11 lore raw

Re: [PATCH] example/ip_pipeline: fix value overwrite

In reply to Fan Zhang
Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Fan Zhang
Sent: Friday, December 11, 2015 11:29 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH] example/ip_pipeline: fix value overwrite

Quoted 5 lines

Coverity issue: 107136

Fixes 7f64b9c004aa ("examples/ip_pipeline: rework config file syntax")
#3 lore raw

Re: [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect

In reply to Mcnamara, John
Quoted 46 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Mcnamara, John
Sent: Friday, December 11, 2015 3:37 PM
To: Zhang, Roy Fan <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect

Quoted 24 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Fan Zhang
Sent: Friday, December 11, 2015 11:29 AM
To: [email protected]
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")

---
 examples/ip_pipeline/init.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
examples/ip_pipeline/init.c +0 -0
index bc6d6d9..5bcb420 100644
@@ -1068,7 +1068,10 @@ static void app_pipeline_params_get(struct
 app_params *app,

examples/ip_pipeline/init.c static void app_pipeline_params_get(struct · line 1077

Quoted 10 lines
examples/ip_pipeline/init.c +4 -1
 	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,

Quoted 8 lines

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