[dpdk-dev] examples/ipsec-secgw: fix buffer not null terminated

Message ID 1478175163-229116-1-git-send-email-roy.fan.zhang@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Fan Zhang Nov. 3, 2016, 12:12 p.m. UTC
  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(-)
  

Comments

Ferruh Yigit Nov. 4, 2016, 2:18 p.m. UTC | #1
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.
  
Thomas Monjalon Nov. 6, 2016, 11:38 p.m. UTC | #2
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
  

Patch

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;
 	}