From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 47F6E1BB31; Fri, 27 Oct 2017 17:08:35 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Oct 2017 08:08:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,304,1505804400"; d="scan'208";a="165816475" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by orsmga005.jf.intel.com with ESMTP; 27 Oct 2017 08:08:33 -0700 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.28]) by IRSMSX153.ger.corp.intel.com ([169.254.9.34]) with mapi id 14.03.0319.002; Fri, 27 Oct 2017 16:08:32 +0100 From: "Jastrzebski, MichalX K" To: "Piasecki, JacekX" , "Dumitrescu, Cristian" CC: "dev@dpdk.org" , "Piasecki, JacekX" , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] cfgfile: fix NULL pointer dereference Thread-Index: AQHTTiPn9oKkYFtgi0yLeY7r8GG4ZqL3zkog Date: Fri, 27 Oct 2017 15:08:31 +0000 Message-ID: <60ABE07DBB3A454EB7FAD707B4BB158213C4B1BF@IRSMSX109.ger.corp.intel.com> References: <1508999046-5012-1-git-send-email-jacekx.piasecki@intel.com> In-Reply-To: <1508999046-5012-1-git-send-email-jacekx.piasecki@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMWU1MTM5OTctMjVmNi00MzA0LWFmOWEtNDNmMTkxY2NiM2E3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImRBR0syRlhibTF6Z2F4SnpHV3ZwTmxJcjhaeU5ESjg1SEgrdjNGYzJ4U2c9In0= x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] cfgfile: fix NULL pointer dereference X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 15:08:36 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jacek Piasecki > Sent: Thursday, October 26, 2017 8:24 AM > To: Dumitrescu, Cristian > Cc: dev@dpdk.org; Piasecki, JacekX ; > stable@dpdk.org > Subject: [dpdk-dev] [PATCH] cfgfile: fix NULL pointer dereference >=20 > Function memchr() could return NULL and assign it to split[1] pointer. > Additional check and error handing is made after memchr() call. >=20 > Coverity issue: 195004 > Fixes: a6a47ac9c2c9 ("cfgfile: rework load function") > Cc: jacekx.piasecki@intel.com > Cc: stable@dpdk.org >=20 > Signed-off-by: Jacek Piasecki > --- > lib/librte_cfgfile/rte_cfgfile.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) >=20 > diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cf= gfile.c > index 124aef5..80077b6 100644 > --- a/lib/librte_cfgfile/rte_cfgfile.c > +++ b/lib/librte_cfgfile/rte_cfgfile.c > @@ -241,6 +241,11 @@ rte_cfgfile_load_with_params(const char > *filename, int flags, >=20 > split[0] =3D buffer; > split[1] =3D memchr(buffer, '=3D', len); > + if (split[1] =3D=3D NULL) { > + printf("Error line %d - no '=3D'" > + "character found\n", lineno); > + goto error1; > + } > *split[1] =3D '\0'; > split[1]++; >=20 > @@ -268,7 +273,7 @@ rte_cfgfile_load_with_params(const char > *filename, int flags, > goto error1; >=20 > _add_entry(&cfg->sections[cfg->num_sections - 1], > - split[0], (split[1] ? split[1] : "")); > + split[0], split[1]); > } > } > fclose(f); > -- > 2.7.4 Acked-by: Michal Jastrzebski