From patchwork Tue Feb 17 02:08:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cunming Liang X-Patchwork-Id: 3390 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 2359FB67D; Tue, 17 Feb 2015 03:08:58 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 251F4B65F for ; Tue, 17 Feb 2015 03:08:51 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 16 Feb 2015 18:04:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,591,1418112000"; d="scan'208";a="528414150" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 16 Feb 2015 18:00:12 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t1H28gs6019588; Tue, 17 Feb 2015 10:08:42 +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 t1H28cxf028705; Tue, 17 Feb 2015 10:08:40 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t1H28cda028701; Tue, 17 Feb 2015 10:08:38 +0800 From: Cunming Liang To: dev@dpdk.org Date: Tue, 17 Feb 2015 10:08:01 +0800 Message-Id: <1424138896-28618-5-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1424138896-28618-1-git-send-email-cunming.liang@intel.com> References: <1423970145-31985-1-git-send-email-cunming.liang@intel.com> <1424138896-28618-1-git-send-email-cunming.liang@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v8 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- v8 changes: keep using strlen for trusted input string v7 changes: rollback to use strnlen v5 changes: using strlen instead of strnlen. lib/librte_eal/common/eal_common_options.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 0b18c55..e227a6a 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -167,7 +167,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 = strlen(coremask); while ((i > 0) && isblank(coremask[i - 1])) i--; if (i == 0) @@ -227,7 +227,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 = strlen(corelist); while ((i > 0) && isblank(corelist[i - 1])) i--; @@ -472,7 +472,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 = strlen(lcores); while ((i > 0) && isblank(lcores[i - 1])) i--;