From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 3583CB51C for ; Sun, 15 Feb 2015 04:16:11 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 14 Feb 2015 19:16:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,579,1418112000"; d="scan'208";a="454796789" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 14 Feb 2015 19:01:18 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t1F3G7DU022643; Sun, 15 Feb 2015 11:16:07 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t1F3G42a032072; Sun, 15 Feb 2015 11:16:06 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t1F3G4qs032068; Sun, 15 Feb 2015 11:16:04 +0800 From: Cunming Liang To: dev@dpdk.org Date: Sun, 15 Feb 2015 11:15:30 +0800 Message-Id: <1423970145-31985-5-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1423970145-31985-1-git-send-email-cunming.liang@intel.com> References: <1423791501-1555-1-git-send-email-cunming.liang@intel.com> <1423970145-31985-1-git-send-email-cunming.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 04/19] eal: fix wrong strnlen() return value in 32bit icc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 03:16:11 -0000 The problem is that strnlen() here may return invalid value with 32bit icc. (actually it returns it’s second parameter,e.g: sysconf(_SC_ARG_MAX)). It starts to manifest hwen max_len parameter is > 2M and using icc –m32 –O2 (or above). Suggested-by: Konstantin Ananyev Signed-off-by: Cunming Liang --- v7 changes: rollback to use strnlen v5 changes: using strlen instead of strnlen. lib/librte_eal/common/eal_common_options.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 178e303..62d9120 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -52,6 +52,7 @@ #include "eal_filesystem.h" #define BITS_PER_HEX 4 +#define EAL_ARG_MAX 4096 const char eal_short_options[] = @@ -167,7 +168,7 @@ eal_parse_coremask(const char *coremask) if (coremask[0] == '0' && ((coremask[1] == 'x') || (coremask[1] == 'X'))) coremask += 2; - i = strnlen(coremask, PATH_MAX); + i = strnlen(coremask, EAL_ARG_MAX); while ((i > 0) && isblank(coremask[i - 1])) i--; if (i == 0) @@ -227,7 +228,7 @@ eal_parse_corelist(const char *corelist) /* Remove all blank characters ahead and after */ while (isblank(*corelist)) corelist++; - i = strnlen(corelist, sysconf(_SC_ARG_MAX)); + i = strnlen(corelist, EAL_ARG_MAX); while ((i > 0) && isblank(corelist[i - 1])) i--; @@ -472,7 +473,7 @@ eal_parse_lcores(const char *lcores) /* Remove all blank characters ahead and after */ while (isblank(*lcores)) lcores++; - i = strnlen(lcores, sysconf(_SC_ARG_MAX)); + i = strnlen(lcores, EAL_ARG_MAX); while ((i > 0) && isblank(lcores[i - 1])) i--; -- 1.8.1.4