examples/ipsec-secgw: fix configuration string termination
authorFan Zhang <roy.fan.zhang@intel.com>
Thu, 3 Nov 2016 12:12:40 +0000 (12:12 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Sun, 6 Nov 2016 23:35:43 +0000 (00:35 +0100)
Coverity issue: 137854, 137855
Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
examples/ipsec-secgw/parser.c

index 99bdfc5..598f435 100644 (file)
@@ -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;
        }
@@ -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;
        }