From: Fan Zhang Date: Mon, 7 Nov 2016 14:21:06 +0000 (+0000) Subject: examples/ipsec-secgw: fix configuration parsing X-Git-Tag: spdx-start~5348 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=63e8c07c7245095406c1d01a4121e05191121754;p=dpdk.git examples/ipsec-secgw: fix configuration parsing Fix copy into fixed size buffer issue. Coverity issue: 137875 Fixes: 0d547ed0 ("examples/ipsec-secgw: support configuration file") Signed-off-by: Fan Zhang Acked-by: Ferruh Yigit --- diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c index 9e2c8a9a8f..8c4406cf8f 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;