DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated
@ 2016-11-03 12:12 Fan Zhang
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not terminated issue Fan Zhang
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Fan Zhang @ 2016-11-03 12:12 UTC (permalink / raw)
  To: dev

Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
Coverity issue: 137854

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 examples/ipsec-secgw/parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c
index 99bdfc5..e09a7c0 100644
--- a/examples/ipsec-secgw/parser.c
+++ b/examples/ipsec-secgw/parser.c
@@ -248,7 +248,7 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask)
 		if (mask)
 			*mask = atoi(pch);
 	} else {
-		strncpy(ip_str, token, sizeof(ip_str));
+		strncpy(ip_str, token, sizeof(ip_str) - 1);
 		if (mask)
 			*mask = 0;
 	}
-- 
2.5.5

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

* [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not terminated issue
  2016-11-03 12:12 [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated Fan Zhang
@ 2016-11-03 12:12 ` Fan Zhang
  2016-11-04 14:16   ` Ferruh Yigit
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix copy into fixed size buffer issue Fan Zhang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: Fan Zhang @ 2016-11-03 12:12 UTC (permalink / raw)
  To: dev

Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
Coverity issue: 137855

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 examples/ipsec-secgw/parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c
index 99bdfc5..ede08d8 100644
--- a/examples/ipsec-secgw/parser.c
+++ b/examples/ipsec-secgw/parser.c
@@ -277,7 +277,7 @@ parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask)
 		if (mask)
 			*mask = atoi(pch);
 	} else {
-		strncpy(ip_str, token, sizeof(ip_str));
+		strncpy(ip_str, token, sizeof(ip_str) - 1);
 		if (mask)
 			*mask = 0;
 	}
-- 
2.5.5

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

* [dpdk-dev] [PATCH] examples/ipsec-secgw: fix copy into fixed size buffer issue
  2016-11-03 12:12 [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated Fan Zhang
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not terminated issue Fan Zhang
@ 2016-11-03 12:12 ` Fan Zhang
  2016-11-04 14:15   ` Ferruh Yigit
  2016-11-07 14:21   ` [dpdk-dev] [PATCH v2] " Fan Zhang
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix pointer to local outside scope Fan Zhang
  2016-11-04 14:18 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated Ferruh Yigit
  3 siblings, 2 replies; 17+ messages in thread
From: Fan Zhang @ 2016-11-03 12:12 UTC (permalink / raw)
  To: dev

Coverity issue: 137875
Fixes: 0d547ed0 ("examples/ipsec-secgw: support configuration
file")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 examples/ipsec-secgw/sa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 9e2c8a9..c891be2 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -177,7 +177,7 @@ parse_key_string(const char *key_str, uint8_t *key)
 		pt_end = strchr(pt_start, ':');
 
 		if (pt_end == NULL)
-			strncpy(sub_str, pt_start, strlen(pt_start));
+			strncpy(sub_str, pt_start, strlen(sub_str) - 1);
 		else {
 			if (pt_end - pt_start > 2)
 				return 0;
-- 
2.5.5

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

* [dpdk-dev] [PATCH] examples/ipsec-secgw: fix pointer to local outside scope
  2016-11-03 12:12 [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated Fan Zhang
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not terminated issue Fan Zhang
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix copy into fixed size buffer issue Fan Zhang
@ 2016-11-03 12:12 ` Fan Zhang
  2016-11-04 14:15   ` Ferruh Yigit
                     ` (2 more replies)
  2016-11-04 14:18 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated Ferruh Yigit
  3 siblings, 3 replies; 17+ messages in thread
From: Fan Zhang @ 2016-11-03 12:12 UTC (permalink / raw)
  To: dev

Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
Coverity issue: 137871

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 examples/ipsec-secgw/parser.c | 124 +++++++++++++++++++++---------------------
 1 file changed, 62 insertions(+), 62 deletions(-)

diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c
index 99bdfc5..45473c7 100644
--- a/examples/ipsec-secgw/parser.c
+++ b/examples/ipsec-secgw/parser.c
@@ -503,86 +503,86 @@ parse_cfg_file(const char *cfg_filename)
 
 	do {
 		char oneline[1024];
-
+		char *pos;
 		get_s = fgets(oneline, 1024, f);
-		if (get_s) {
-			char *pos;
 
-			line_num++;
+		if (!get_s)
+			break;
 
-			if (strlen(oneline) > 1022) {
-				rte_panic("%s:%u: error: the line "
-					"contains more characters the "
-					"parser can handle\n",
-					cfg_filename, line_num);
-				goto error_exit;
-			}
+		line_num++;
 
-			/* process comment char '#' */
-			if (oneline[0] == '#')
-				continue;
+		if (strlen(oneline) > 1022) {
+			rte_panic("%s:%u: error: the line "
+				"contains more characters the "
+				"parser can handle\n",
+				cfg_filename, line_num);
+			goto error_exit;
+		}
 
-			pos = strchr(oneline, '#');
-			if (pos != NULL)
-				*pos = '\0';
-
-			/* process line concatenator '\' */
-			pos = strchr(oneline, 92);
-			if (pos != NULL) {
-				if (pos != oneline+strlen(oneline) - 2) {
-					rte_panic("%s:%u: error: no "
-						"character should exist "
-						"after '\\' symbol\n",
-						cfg_filename, line_num);
-					goto error_exit;
-				}
-
-				*pos = '\0';
-
-				if (strlen(oneline) + strlen(str) > 1022) {
-					rte_panic("%s:%u: error: the "
-						"concatenated line "
-						"contains more characters "
-						"the parser can handle\n",
-						cfg_filename, line_num);
-					goto error_exit;
-				}
-
-				strncpy(str + strlen(str), oneline,
-					strlen(oneline));
+		/* process comment char '#' */
+		if (oneline[0] == '#')
+			continue;
 
-				continue;
+		pos = strchr(oneline, '#');
+		if (pos != NULL)
+			*pos = '\0';
+
+		/* process line concatenator '\' */
+		pos = strchr(oneline, 92);
+		if (pos != NULL) {
+			if (pos != oneline+strlen(oneline) - 2) {
+				rte_panic("%s:%u: error: no "
+					"character should exist "
+					"after '\\' symbol\n",
+					cfg_filename, line_num);
+				goto error_exit;
 			}
 
-			/* copy the line to str and process */
+			*pos = '\0';
+
 			if (strlen(oneline) + strlen(str) > 1022) {
-				rte_panic("%s:%u: error: the line "
-					"contains more characters the "
-					"parser can handle\n",
+				rte_panic("%s:%u: error: the "
+					"concatenated line "
+					"contains more characters "
+					"the parser can handle\n",
 					cfg_filename, line_num);
 				goto error_exit;
 			}
+
 			strncpy(str + strlen(str), oneline,
 				strlen(oneline));
 
-			str[strlen(str)] = '\n';
-			if (cmdline_parse(cl, str) < 0) {
-				rte_panic("%s:%u: error: parsing \"%s\" "
-					"failed\n", cfg_filename,
-					line_num, str);
-				goto error_exit;
-			}
+			continue;
+		}
 
-			if (status.status < 0) {
-				rte_panic("%s:%u: error: %s",
-					cfg_filename, line_num,
-					status.parse_msg);
-				goto error_exit;
-			}
+		/* copy the line to str and process */
+		if (strlen(oneline) + strlen(str) > 1022) {
+			rte_panic("%s:%u: error: the line "
+				"contains more characters the "
+				"parser can handle\n",
+				cfg_filename, line_num);
+			goto error_exit;
+		}
+		strncpy(str + strlen(str), oneline,
+			strlen(oneline));
+
+		str[strlen(str)] = '\n';
+		if (cmdline_parse(cl, str) < 0) {
+			rte_panic("%s:%u: error: parsing \"%s\" "
+				"failed\n", cfg_filename,
+				line_num, str);
+			goto error_exit;
+		}
 
-			memset(str, 0, 1024);
+		if (status.status < 0) {
+			rte_panic("%s:%u: error: %s",
+				cfg_filename, line_num,
+				status.parse_msg);
+			goto error_exit;
 		}
-	} while (get_s != NULL);
+
+		memset(str, 0, 1024);
+	} while (1);
 
 	cmdline_stdin_exit(cl);
 	fclose(f);
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH] examples/ipsec-secgw: fix pointer to local outside scope
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix pointer to local outside scope Fan Zhang
@ 2016-11-04 14:15   ` Ferruh Yigit
  2016-11-07 14:22   ` [dpdk-dev] [PATCH v2] " Fan Zhang
  2016-11-07 17:25   ` [dpdk-dev] [PATCH v3] " Fan Zhang
  2 siblings, 0 replies; 17+ messages in thread
From: Ferruh Yigit @ 2016-11-04 14:15 UTC (permalink / raw)
  To: Fan Zhang, dev

On 11/3/2016 12:12 PM, Fan Zhang wrote:
> Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
> Coverity issue: 137871
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---

Coverity issue fix looks good to me, but since indentation level reduced
one level, many line wrappings can be re-arranged.

Apart from line wrappings,
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

* Re: [dpdk-dev] [PATCH] examples/ipsec-secgw: fix copy into fixed size buffer issue
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix copy into fixed size buffer issue Fan Zhang
@ 2016-11-04 14:15   ` Ferruh Yigit
  2016-11-07 14:21   ` [dpdk-dev] [PATCH v2] " Fan Zhang
  1 sibling, 0 replies; 17+ messages in thread
From: Ferruh Yigit @ 2016-11-04 14:15 UTC (permalink / raw)
  To: Fan Zhang, dev

On 11/3/2016 12:12 PM, Fan Zhang wrote:
> Coverity issue: 137875
> Fixes: 0d547ed0 ("examples/ipsec-secgw: support configuration
> file")
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---
>  examples/ipsec-secgw/sa.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
> index 9e2c8a9..c891be2 100644
> --- a/examples/ipsec-secgw/sa.c
> +++ b/examples/ipsec-secgw/sa.c
> @@ -177,7 +177,7 @@ parse_key_string(const char *key_str, uint8_t *key)
>  		pt_end = strchr(pt_start, ':');
>  
>  		if (pt_end == NULL)
> -			strncpy(sub_str, pt_start, strlen(pt_start));
> +			strncpy(sub_str, pt_start, strlen(sub_str) - 1);

sub_str initial value is not known, "strlen(sub_str) - 1" leaves last
byte of the string random, instead of intended NULL.

Also sub_str has hardcoded length of 3, it can be good to confirm NULL
terminated byte taken into account, and number actually can be maximum
two digits long.

>  		else {
>  			if (pt_end - pt_start > 2)
>  				return 0;
> 

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

* Re: [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not terminated issue
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not terminated issue Fan Zhang
@ 2016-11-04 14:16   ` Ferruh Yigit
  2016-11-06 23:38     ` Thomas Monjalon
  0 siblings, 1 reply; 17+ messages in thread
From: Ferruh Yigit @ 2016-11-04 14:16 UTC (permalink / raw)
  To: Fan Zhang, dev

On 11/3/2016 12:12 PM, Fan Zhang wrote:
> Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
> Coverity issue: 137855
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

* Re: [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated
  2016-11-03 12:12 [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated Fan Zhang
                   ` (2 preceding siblings ...)
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix pointer to local outside scope Fan Zhang
@ 2016-11-04 14:18 ` Ferruh Yigit
  2016-11-06 23:38   ` Thomas Monjalon
  3 siblings, 1 reply; 17+ messages in thread
From: Ferruh Yigit @ 2016-11-04 14:18 UTC (permalink / raw)
  To: Fan Zhang, dev

On 11/3/2016 12:12 PM, Fan Zhang wrote:
> Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
> Coverity issue: 137854
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>


Minor nit, for all coverity fixes, defined commit log format is:

Coverity issue: xxxxx
Fixes: .....

Basically two lines should be swapped, but I guess this can be fixed
while applying instead of sending a new version for this.

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

* Re: [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not terminated issue
  2016-11-04 14:16   ` Ferruh Yigit
@ 2016-11-06 23:38     ` Thomas Monjalon
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2016-11-06 23:38 UTC (permalink / raw)
  To: Fan Zhang; +Cc: dev, Ferruh Yigit

2016-11-04 14:16, Ferruh Yigit:
> On 11/3/2016 12:12 PM, Fan Zhang wrote:
> > Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
> > Coverity issue: 137855
> > 
> > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Merged with previous patch and applied

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

* Re: [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated
  2016-11-04 14:18 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated Ferruh Yigit
@ 2016-11-06 23:38   ` Thomas Monjalon
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2016-11-06 23:38 UTC (permalink / raw)
  To: Fan Zhang; +Cc: dev, Ferruh Yigit

2016-11-04 14:18, Ferruh Yigit:
> On 11/3/2016 12:12 PM, Fan Zhang wrote:
> > Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
> > Coverity issue: 137854
> > 
> > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
> 
> 
> Minor nit, for all coverity fixes, defined commit log format is:
> 
> Coverity issue: xxxxx
> Fixes: .....
> 
> Basically two lines should be swapped, but I guess this can be fixed
> while applying instead of sending a new version for this.

Applied, thanks

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

* [dpdk-dev] [PATCH v2] examples/ipsec-secgw: fix copy into fixed size buffer issue
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix copy into fixed size buffer issue Fan Zhang
  2016-11-04 14:15   ` Ferruh Yigit
@ 2016-11-07 14:21   ` Fan Zhang
  2016-11-07 15:59     ` Ferruh Yigit
  1 sibling, 1 reply; 17+ messages in thread
From: Fan Zhang @ 2016-11-07 14:21 UTC (permalink / raw)
  To: dev; +Cc: sergio.gonzalez.monroy

Fixes: 0d547ed0 ("examples/ipsec-secgw: support configuration
file")
Coverity issue: 137875

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 examples/ipsec-secgw/sa.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 9e2c8a9..8c4406c 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -170,15 +170,18 @@ static uint32_t
 parse_key_string(const char *key_str, uint8_t *key)
 {
 	const char *pt_start = key_str, *pt_end = key_str;
-	char sub_str[3];
 	uint32_t nb_bytes = 0;
 
 	while (pt_end != NULL) {
+		char sub_str[3] = {0};
+
 		pt_end = strchr(pt_start, ':');
 
-		if (pt_end == NULL)
-			strncpy(sub_str, pt_start, strlen(pt_start));
-		else {
+		if (pt_end == NULL) {
+			if (strlen(pt_start) > 2)
+				return 0;
+			strncpy(sub_str, pt_start, 2);
+		} else {
 			if (pt_end - pt_start > 2)
 				return 0;
 
-- 
2.5.5

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

* [dpdk-dev] [PATCH v2] examples/ipsec-secgw: fix pointer to local outside scope
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix pointer to local outside scope Fan Zhang
  2016-11-04 14:15   ` Ferruh Yigit
@ 2016-11-07 14:22   ` Fan Zhang
  2016-11-07 17:25   ` [dpdk-dev] [PATCH v3] " Fan Zhang
  2 siblings, 0 replies; 17+ messages in thread
From: Fan Zhang @ 2016-11-07 14:22 UTC (permalink / raw)
  To: dev; +Cc: sergio.gonzalez.monroy

Coverity issue: 137871
Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 examples/ipsec-secgw/parser.c | 120 ++++++++++++++++++++----------------------
 1 file changed, 58 insertions(+), 62 deletions(-)

diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c
index ede08d8..f1afdb7 100644
--- a/examples/ipsec-secgw/parser.c
+++ b/examples/ipsec-secgw/parser.c
@@ -503,86 +503,82 @@ parse_cfg_file(const char *cfg_filename)
 
 	do {
 		char oneline[1024];
-
+		char *pos;
 		get_s = fgets(oneline, 1024, f);
-		if (get_s) {
-			char *pos;
 
-			line_num++;
+		if (!get_s)
+			break;
 
-			if (strlen(oneline) > 1022) {
-				rte_panic("%s:%u: error: the line "
-					"contains more characters the "
-					"parser can handle\n",
-					cfg_filename, line_num);
-				goto error_exit;
-			}
+		line_num++;
 
-			/* process comment char '#' */
-			if (oneline[0] == '#')
-				continue;
+		if (strlen(oneline) > 1022) {
+			rte_panic("%s:%u: error: the line "
+				"contains more characters the "
+				"parser can handle\n",
+				cfg_filename, line_num);
+			goto error_exit;
+		}
 
-			pos = strchr(oneline, '#');
-			if (pos != NULL)
-				*pos = '\0';
-
-			/* process line concatenator '\' */
-			pos = strchr(oneline, 92);
-			if (pos != NULL) {
-				if (pos != oneline+strlen(oneline) - 2) {
-					rte_panic("%s:%u: error: no "
-						"character should exist "
-						"after '\\' symbol\n",
-						cfg_filename, line_num);
-					goto error_exit;
-				}
-
-				*pos = '\0';
-
-				if (strlen(oneline) + strlen(str) > 1022) {
-					rte_panic("%s:%u: error: the "
-						"concatenated line "
-						"contains more characters "
-						"the parser can handle\n",
-						cfg_filename, line_num);
-					goto error_exit;
-				}
-
-				strncpy(str + strlen(str), oneline,
-					strlen(oneline));
+		/* process comment char '#' */
+		if (oneline[0] == '#')
+			continue;
 
-				continue;
+		pos = strchr(oneline, '#');
+		if (pos != NULL)
+			*pos = '\0';
+
+		/* process line concatenator '\' */
+		pos = strchr(oneline, 92);
+		if (pos != NULL) {
+			if (pos != oneline+strlen(oneline) - 2) {
+				rte_panic("%s:%u: error: no character "
+					"should exist after '\\'\n",
+					cfg_filename, line_num);
+				goto error_exit;
 			}
 
-			/* copy the line to str and process */
+			*pos = '\0';
+
 			if (strlen(oneline) + strlen(str) > 1022) {
-				rte_panic("%s:%u: error: the line "
-					"contains more characters the "
-					"parser can handle\n",
+				rte_panic("%s:%u: error: the "
+					"concatenated line contains more "
+					"characters the parser can "
+					"handle\n",
 					cfg_filename, line_num);
 				goto error_exit;
 			}
+
 			strncpy(str + strlen(str), oneline,
 				strlen(oneline));
 
-			str[strlen(str)] = '\n';
-			if (cmdline_parse(cl, str) < 0) {
-				rte_panic("%s:%u: error: parsing \"%s\" "
-					"failed\n", cfg_filename,
-					line_num, str);
-				goto error_exit;
-			}
+			continue;
+		}
 
-			if (status.status < 0) {
-				rte_panic("%s:%u: error: %s",
-					cfg_filename, line_num,
-					status.parse_msg);
-				goto error_exit;
-			}
+		/* copy the line to str and process */
+		if (strlen(oneline) + strlen(str) > 1022) {
+			rte_panic("%s:%u: error: the line contains more "
+				"characters the parser can handle\n",
+				cfg_filename, line_num);
+			goto error_exit;
+		}
+		strncpy(str + strlen(str), oneline,
+			strlen(oneline));
+
+		str[strlen(str)] = '\n';
+		if (cmdline_parse(cl, str) < 0) {
+			rte_panic("%s:%u: error: parsing \"%s\" failed\n",
+				cfg_filename, line_num, str);
+			goto error_exit;
+		}
 
-			memset(str, 0, 1024);
+		if (status.status < 0) {
+			rte_panic("%s:%u: error: %s", cfg_filename,
+				line_num, status.parse_msg);
+			goto error_exit;
 		}
-	} while (get_s != NULL);
+
+		memset(str, 0, 1024);
+	} while (1);
 
 	cmdline_stdin_exit(cl);
 	fclose(f);
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH v2] examples/ipsec-secgw: fix copy into fixed size buffer issue
  2016-11-07 14:21   ` [dpdk-dev] [PATCH v2] " Fan Zhang
@ 2016-11-07 15:59     ` Ferruh Yigit
  2016-11-07 20:40       ` Thomas Monjalon
  0 siblings, 1 reply; 17+ messages in thread
From: Ferruh Yigit @ 2016-11-07 15:59 UTC (permalink / raw)
  To: Fan Zhang, dev; +Cc: sergio.gonzalez.monroy

On 11/7/2016 2:21 PM, Fan Zhang wrote:
> Fixes: 0d547ed0 ("examples/ipsec-secgw: support configuration
> file")
> Coverity issue: 137875
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

* [dpdk-dev] [PATCH v3] examples/ipsec-secgw: fix pointer to local outside scope
  2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix pointer to local outside scope Fan Zhang
  2016-11-04 14:15   ` Ferruh Yigit
  2016-11-07 14:22   ` [dpdk-dev] [PATCH v2] " Fan Zhang
@ 2016-11-07 17:25   ` Fan Zhang
  2016-11-07 17:31     ` Ferruh Yigit
  2 siblings, 1 reply; 17+ messages in thread
From: Fan Zhang @ 2016-11-07 17:25 UTC (permalink / raw)
  To: dev; +Cc: sergio.gonzalez.monroy

Coverity issue: 137871
Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 examples/ipsec-secgw/parser.c | 116 +++++++++++++++++++-----------------------
 1 file changed, 52 insertions(+), 64 deletions(-)

diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c
index 598f435..c5f2508 100644
--- a/examples/ipsec-secgw/parser.c
+++ b/examples/ipsec-secgw/parser.c
@@ -487,8 +487,7 @@ parse_cfg_file(const char *cfg_filename)
 	struct parse_status status = {0};
 
 	if (f == NULL) {
-		rte_panic("Error: invalid file descriptor %s\n",
-			cfg_filename);
+		rte_panic("Error: invalid file descriptor %s\n", cfg_filename);
 		goto error_exit;
 	}
 
@@ -503,86 +502,75 @@ parse_cfg_file(const char *cfg_filename)
 
 	do {
 		char oneline[1024];
-
+		char *pos;
 		get_s = fgets(oneline, 1024, f);
-		if (get_s) {
-			char *pos;
 
-			line_num++;
+		if (!get_s)
+			break;
 
-			if (strlen(oneline) > 1022) {
-				rte_panic("%s:%u: error: the line "
-					"contains more characters the "
-					"parser can handle\n",
-					cfg_filename, line_num);
-				goto error_exit;
-			}
+		line_num++;
 
-			/* process comment char '#' */
-			if (oneline[0] == '#')
-				continue;
+		if (strlen(oneline) > 1022) {
+			rte_panic("%s:%u: error: the line contains more characters the parser can handle\n",
+				cfg_filename, line_num);
+			goto error_exit;
+		}
 
-			pos = strchr(oneline, '#');
-			if (pos != NULL)
-				*pos = '\0';
-
-			/* process line concatenator '\' */
-			pos = strchr(oneline, 92);
-			if (pos != NULL) {
-				if (pos != oneline+strlen(oneline) - 2) {
-					rte_panic("%s:%u: error: no "
-						"character should exist "
-						"after '\\' symbol\n",
-						cfg_filename, line_num);
-					goto error_exit;
-				}
-
-				*pos = '\0';
-
-				if (strlen(oneline) + strlen(str) > 1022) {
-					rte_panic("%s:%u: error: the "
-						"concatenated line "
-						"contains more characters "
-						"the parser can handle\n",
-						cfg_filename, line_num);
-					goto error_exit;
-				}
-
-				strncpy(str + strlen(str), oneline,
-					strlen(oneline));
+		/* process comment char '#' */
+		if (oneline[0] == '#')
+			continue;
 
-				continue;
+		pos = strchr(oneline, '#');
+		if (pos != NULL)
+			*pos = '\0';
+
+		/* process line concatenator '\' */
+		pos = strchr(oneline, 92);
+		if (pos != NULL) {
+			if (pos != oneline+strlen(oneline) - 2) {
+				rte_panic("%s:%u: error: no character should exist after '\\'\n",
+					cfg_filename, line_num);
+				goto error_exit;
 			}
 
-			/* copy the line to str and process */
+			*pos = '\0';
+
 			if (strlen(oneline) + strlen(str) > 1022) {
-				rte_panic("%s:%u: error: the line "
-					"contains more characters the "
-					"parser can handle\n",
+				rte_panic("%s:%u: error: the concatenated line contains more characters the parser can handle\n",
 					cfg_filename, line_num);
 				goto error_exit;
 			}
+
 			strncpy(str + strlen(str), oneline,
 				strlen(oneline));
 
-			str[strlen(str)] = '\n';
-			if (cmdline_parse(cl, str) < 0) {
-				rte_panic("%s:%u: error: parsing \"%s\" "
-					"failed\n", cfg_filename,
-					line_num, str);
-				goto error_exit;
-			}
+			continue;
+		}
 
-			if (status.status < 0) {
-				rte_panic("%s:%u: error: %s",
-					cfg_filename, line_num,
-					status.parse_msg);
-				goto error_exit;
-			}
+		/* copy the line to str and process */
+		if (strlen(oneline) + strlen(str) > 1022) {
+			rte_panic("%s:%u: error: the line contains more characters the parser can handle\n",
+				cfg_filename, line_num);
+			goto error_exit;
+		}
+		strncpy(str + strlen(str), oneline,
+			strlen(oneline));
+
+		str[strlen(str)] = '\n';
+		if (cmdline_parse(cl, str) < 0) {
+			rte_panic("%s:%u: error: parsing \"%s\" failed\n",
+				cfg_filename, line_num, str);
+			goto error_exit;
+		}
 
-			memset(str, 0, 1024);
+		if (status.status < 0) {
+			rte_panic("%s:%u: error: %s", cfg_filename,
+				line_num, status.parse_msg);
+			goto error_exit;
 		}
-	} while (get_s != NULL);
+
+		memset(str, 0, 1024);
+	} while (1);
 
 	cmdline_stdin_exit(cl);
 	fclose(f);
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH v3] examples/ipsec-secgw: fix pointer to local outside scope
  2016-11-07 17:25   ` [dpdk-dev] [PATCH v3] " Fan Zhang
@ 2016-11-07 17:31     ` Ferruh Yigit
  2016-11-07 20:48       ` Thomas Monjalon
  0 siblings, 1 reply; 17+ messages in thread
From: Ferruh Yigit @ 2016-11-07 17:31 UTC (permalink / raw)
  To: Fan Zhang, dev; +Cc: sergio.gonzalez.monroy

On 11/7/2016 5:25 PM, Fan Zhang wrote:
> Coverity issue: 137871
> Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---

Although checkpatch will complain about long lines, I believe it is
better not to wrap log messages.

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

* Re: [dpdk-dev] [PATCH v2] examples/ipsec-secgw: fix copy into fixed size buffer issue
  2016-11-07 15:59     ` Ferruh Yigit
@ 2016-11-07 20:40       ` Thomas Monjalon
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2016-11-07 20:40 UTC (permalink / raw)
  To: Fan Zhang; +Cc: dev, Ferruh Yigit, sergio.gonzalez.monroy

2016-11-07 15:59, Ferruh Yigit:
> On 11/7/2016 2:21 PM, Fan Zhang wrote:
> > Fixes: 0d547ed0 ("examples/ipsec-secgw: support configuration
> > file")
> > Coverity issue: 137875
> > 
> > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied

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

* Re: [dpdk-dev] [PATCH v3] examples/ipsec-secgw: fix pointer to local outside scope
  2016-11-07 17:31     ` Ferruh Yigit
@ 2016-11-07 20:48       ` Thomas Monjalon
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2016-11-07 20:48 UTC (permalink / raw)
  To: Fan Zhang; +Cc: dev, Ferruh Yigit, sergio.gonzalez.monroy

2016-11-07 17:31, Ferruh Yigit:
> On 11/7/2016 5:25 PM, Fan Zhang wrote:
> > Coverity issue: 137871
> > Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
> > 
> > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> 
> Although checkpatch will complain about long lines, I believe it is
> better not to wrap log messages.
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Wrapped after "error: " to avoid too long lines
while being able to grep the rest of the message,
and applied.

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

end of thread, other threads:[~2016-11-07 20:48 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-03 12:12 [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated Fan Zhang
2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not terminated issue Fan Zhang
2016-11-04 14:16   ` Ferruh Yigit
2016-11-06 23:38     ` Thomas Monjalon
2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix copy into fixed size buffer issue Fan Zhang
2016-11-04 14:15   ` Ferruh Yigit
2016-11-07 14:21   ` [dpdk-dev] [PATCH v2] " Fan Zhang
2016-11-07 15:59     ` Ferruh Yigit
2016-11-07 20:40       ` Thomas Monjalon
2016-11-03 12:12 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix pointer to local outside scope Fan Zhang
2016-11-04 14:15   ` Ferruh Yigit
2016-11-07 14:22   ` [dpdk-dev] [PATCH v2] " Fan Zhang
2016-11-07 17:25   ` [dpdk-dev] [PATCH v3] " Fan Zhang
2016-11-07 17:31     ` Ferruh Yigit
2016-11-07 20:48       ` Thomas Monjalon
2016-11-04 14:18 ` [dpdk-dev] [PATCH] examples/ipsec-secgw: fix buffer not null terminated Ferruh Yigit
2016-11-06 23:38   ` Thomas Monjalon

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