From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cunming Liang Subject: [PATCH v8 04/19] eal: fix wrong strnlen() return value in 32bit icc Date: Tue, 17 Feb 2015 10:08:01 +0800 Message-ID: <1424138896-28618-5-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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1424138896-28618-1-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" The problem is that strnlen() here may return invalid value with 32bit ic= c. (actually it returns it=E2=80=99s second parameter,e.g: sysconf(_SC_ARG_M= AX)). It starts to manifest hwen max_len parameter is > 2M and using icc =E2=80= =93m32 =E2=80=93O2 (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] =3D=3D '0' && ((coremask[1] =3D=3D 'x') || (coremask[1] =3D=3D 'X'))) coremask +=3D 2; - i =3D strnlen(coremask, PATH_MAX); + i =3D strlen(coremask); while ((i > 0) && isblank(coremask[i - 1])) i--; if (i =3D=3D 0) @@ -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 strlen(corelist); while ((i > 0) && isblank(corelist[i - 1])) i--; =20 @@ -472,7 +472,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 strlen(lcores); while ((i > 0) && isblank(lcores[i - 1])) i--; =20 --=20 1.8.1.4