From: Fan Zhang <roy.fan.zhang@intel.com>
To: dev@dpdk.org
Cc: sergio.gonzalez.monroy@intel.com
Subject: [dpdk-dev] [PATCH v2] examples/ipsec-secgw: fix copy into fixed size buffer issue
Date: Mon, 7 Nov 2016 14:21:06 +0000 [thread overview]
Message-ID: <1478528466-211016-1-git-send-email-roy.fan.zhang@intel.com> (raw)
In-Reply-To: <1478175163-229116-3-git-send-email-roy.fan.zhang@intel.com>
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
next prev parent reply other threads:[~2016-11-07 14:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Fan Zhang [this message]
2016-11-07 15:59 ` [dpdk-dev] [PATCH v2] " 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
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=1478528466-211016-1-git-send-email-roy.fan.zhang@intel.com \
--to=roy.fan.zhang@intel.com \
--cc=dev@dpdk.org \
--cc=sergio.gonzalez.monroy@intel.com \
/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).