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: Sun, 08 Feb 2015 20:59:57 +0100 Message-ID: <54D7C03D.8030204@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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: Cunming Liang , dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1422842559-13617-4-git-send-email-cunming.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 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/02/2015 03:02 AM, Cunming Liang wrote: > The problem is that strnlen() here may return invalid value with 32bit = icc. > (actually it returns it=E2=80=99s second parameter,e.g: sysconf(_SC_ARG= _MAX)). > It starts to manifest hwen max_len parameter is > 2M and using icc =E2=80= =93m32 =E2=80=93O2 (or above). >=20 > Suggested-by: Konstantin Ananyev > Signed-off-by: Cunming Liang > --- > lib/librte_eal/common/eal_common_options.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_ea= l/common/eal_common_options.c > index 29ebb6f..22d5d37 100644 > --- a/lib/librte_eal/common/eal_common_options.c > +++ b/lib/librte_eal/common/eal_common_options.c > @@ -227,7 +227,7 @@ eal_parse_corelist(const char *corelist) > /* Remove all blank characters ahead and after */ > while (isblank(*corelist)) > corelist++; > - i =3D strnlen(corelist, sysconf(_SC_ARG_MAX)); > + i =3D strnlen(corelist, PATH_MAX); > while ((i > 0) && isblank(corelist[i - 1])) > i--; > =20 > @@ -469,7 +469,7 @@ eal_parse_lcores(const char *lcores) > /* Remove all blank characters ahead and after */ > while (isblank(*lcores)) > lcores++; > - i =3D strnlen(lcores, sysconf(_SC_ARG_MAX)); > + i =3D strnlen(lcores, PATH_MAX); > while ((i > 0) && isblank(lcores[i - 1])) > i--; > =20 >=20 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. Regards, Olivier