From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier MATZ Subject: Re: [PATCH v4 03/17] eal: fix wrong strnlen() return value in 32bit icc Date: Mon, 09 Feb 2015 18:13:16 +0100 Message-ID: <54D8EAAC.5030501@6wind.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: "Liang, Cunming" , "dev-VfR2kkLFssw@public.gmane.org" Return-path: In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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