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
Subject: [dpdk-dev] [PATCH] examples/ipsec-secgw: fix ip address parsing
Date: Mon, 14 May 2018 11:00:51 +0100 [thread overview]
Message-ID: <1526292051-58151-1-git-send-email-kirill.rybalchenko@intel.com> (raw)
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
next reply other threads:[~2018-05-14 10:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-14 10:00 Kirill Rybalchenko [this message]
2018-05-14 11:25 ` De Lara Guarch, Pablo
2018-05-14 12:09 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1526292051-58151-1-git-send-email-kirill.rybalchenko@intel.com \
--to=kirill.rybalchenko@intel.com \
--cc=akhil.goyal@nxp.com \
--cc=dev@dpdk.org \
--cc=pablo.de.lara.guarch@intel.com \
--cc=radu.nicolau@intel.com \
--cc=reshma.pattan@intel.com \
--cc=roy.fan.zhang@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).