From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id B863858F4 for ; Mon, 9 Feb 2015 18:13:26 +0100 (CET) Received: from was59-1-82-226-113-214.fbx.proxad.net ([82.226.113.214] helo=[192.168.0.10]) by mail.droids-corp.org with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YKrxN-0006jd-TA; Mon, 09 Feb 2015 18:17:14 +0100 Message-ID: <54D8EAAC.5030501@6wind.com> Date: Mon, 09 Feb 2015 18:13:16 +0100 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-Version: 1.0 To: "Liang, Cunming" , "dev@dpdk.org" References: <1422491072-5114-1-git-send-email-cunming.liang@intel.com> <1422842559-13617-1-git-send-email-cunming.liang@intel.com> <1422842559-13617-4-git-send-email-cunming.liang@intel.com> <54D7C03D.8030204@6wind.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 03/17] 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: Mon, 09 Feb 2015 17:13:26 -0000 Hi, On 02/09/2015 12:57 PM, Liang, Cunming wrote: >>> @@ -469,7 +469,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, PATH_MAX); >>> while ((i > 0) && isblank(lcores[i - 1])) >>> i--; >>> >>> >> >> I think PATH_MAX is not equivalent to _SC_ARG_MAX. >> >> But the main question is: why do we need to use strnlen() here instead >> of strlen? We can expect that argv[] pointers are always nul-terminated. >> Replacing them by strlen() would probably also solve the icc issue. > [LCM] You're right, here strlen() also solve icc issue and no risk for argv[]. > But follows practice suggestion, keeping using those with 'n' function in DPDK is not bad. > There's additional two reason to keep strnlen and PATH_MAX. > 1. PATH_MAX is defined as 4096 which is enough as our input. It doesn't matter to be _SC_ARG_MAX or not. PATH_MAX is 4096 but it's not related to the maximum argument length. > 2. strnlen and PATH_MAX already used in eal_parse_coremask, to keep the style consistent in '-l' and '--lcores'. I don't think it's a valid argument. What is the problem of using strlen()? It looks it solves all the issues. Using strlen on valid strings is not a security issue. Regards, Olivier