From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <kirill.rybalchenko@intel.com>
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id 720797D08;
 Mon, 14 May 2018 12:01:00 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga007.jf.intel.com ([10.7.209.58])
 by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 14 May 2018 03:00:57 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.49,399,1520924400"; d="scan'208";a="40750850"
Received: from silpixa00389036.ir.intel.com (HELO
 silpixa00389036.ger.corp.intel.com) ([10.237.223.231])
 by orsmga007.jf.intel.com with ESMTP; 14 May 2018 03:00:55 -0700
From: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
To: dev@dpdk.org
Cc: stable@dpdk.org, kirill.rybalchenko@intel.com, radu.nicolau@intel.com,
 akhil.goyal@nxp.com, roy.fan.zhang@intel.com, reshma.pattan@intel.com,
 pablo.de.lara.guarch@intel.com
Date: Mon, 14 May 2018 11:00:51 +0100
Message-Id: <1526292051-58151-1-git-send-email-kirill.rybalchenko@intel.com>
X-Mailer: git-send-email 2.5.5
Subject: [dpdk-stable] [PATCH] examples/ipsec-secgw: fix ip address parsing
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://dpdk.org/ml/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://dpdk.org/ml/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 14 May 2018 10:01:01 -0000

In strlcpy function parameters there was no allowance for
null terminator, so ip address was copied without last character.

Fixes: ae943ebe1ed3 ("examples/ipsec-secgw: replace strncpy with strlcpy")

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 examples/ipsec-secgw/parser.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c
index e2e3429..91282ca 100644
--- a/examples/ipsec-secgw/parser.c
+++ b/examples/ipsec-secgw/parser.c
@@ -213,8 +213,9 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask)
 
 	pch = strchr(token, '/');
 	if (pch != NULL) {
-		strlcpy(ip_str, token, RTE_MIN((unsigned int long)(pch - token),
-					sizeof(ip_str)));
+		strlcpy(ip_str, token,
+			RTE_MIN((unsigned int long)(pch - token + 1),
+			sizeof(ip_str)));
 		pch += 1;
 		if (is_str_num(pch) != 0)
 			return -EINVAL;
@@ -225,7 +226,6 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask)
 		if (mask)
 			*mask = 0;
 	}
-
 	if (strlen(ip_str) >= INET_ADDRSTRLEN)
 		return -EINVAL;
 
@@ -243,7 +243,8 @@ parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask)
 
 	pch = strchr(token, '/');
 	if (pch != NULL) {
-		strlcpy(ip_str, token, RTE_MIN((unsigned int long)(pch - token),
+		strlcpy(ip_str, token,
+			RTE_MIN((unsigned int long)(pch - token + 1),
 					sizeof(ip_str)));
 		pch += 1;
 		if (is_str_num(pch) != 0)
-- 
2.5.5