From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id BB84A1B1CC; Wed, 9 May 2018 13:35:35 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 04:35:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,381,1520924400"; d="scan'208";a="40432057" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by orsmga006.jf.intel.com with ESMTP; 09 May 2018 04:35:32 -0700 From: Reshma Pattan To: dev@dpdk.org Cc: stable@dpdk.org, "Zhang,Roy Fan" , Reshma Pattan Date: Wed, 9 May 2018 12:35:27 +0100 Message-Id: <1525865729-16086-1-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] examples/ipsec-secgw: replace strncpy with strlcpy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 May 2018 11:35:36 -0000 Use strlcpy instead of strncpy. Fixes: 0d547ed037 ("examples/ipsec-secgw: support configuration file") Fixes: 07b156199f ("examples/ipsec-secgw: fix configuration string termination") Fixes: a1469c319f ("examples/ipsec-secgw: fix configuration parsing") Cc: stable@dpdk.org CC: Zhang,Roy Fan Signed-off-by: Reshma Pattan --- examples/ipsec-secgw/parser.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c index 2403b564d..9ccd5ea72 100644 --- a/examples/ipsec-secgw/parser.c +++ b/examples/ipsec-secgw/parser.c @@ -3,6 +3,7 @@ */ #include #include +#include #include #include @@ -212,14 +213,14 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask) pch = strchr(token, '/'); if (pch != NULL) { - strncpy(ip_str, token, pch - token); + strlcpy(ip_str, token, pch - token); pch += 1; if (is_str_num(pch) != 0) return -EINVAL; if (mask) *mask = atoi(pch); } else { - strncpy(ip_str, token, sizeof(ip_str) - 1); + strlcpy(ip_str, token, sizeof(ip_str) - 1); if (mask) *mask = 0; } @@ -241,14 +242,14 @@ parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask) pch = strchr(token, '/'); if (pch != NULL) { - strncpy(ip_str, token, pch - token); + strlcpy(ip_str, token, pch - token); pch += 1; if (is_str_num(pch) != 0) return -EINVAL; if (mask) *mask = atoi(pch); } else { - strncpy(ip_str, token, sizeof(ip_str) - 1); + strlcpy(ip_str, token, sizeof(ip_str) - 1); if (mask) *mask = 0; } @@ -515,7 +516,7 @@ parse_cfg_file(const char *cfg_filename) goto error_exit; } - strncpy(str + strlen(str), oneline, + strlcpy(str + strlen(str), oneline, strlen(oneline)); continue; @@ -528,7 +529,7 @@ parse_cfg_file(const char *cfg_filename) cfg_filename, line_num); goto error_exit; } - strncpy(str + strlen(str), oneline, + strlcpy(str + strlen(str), oneline, strlen(oneline)); str[strlen(str)] = '\n'; -- 2.14.3