From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 80A6721FCA293 for ; Wed, 1 Nov 2017 18:09:35 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2017 18:13:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,331,1505804400"; d="scan'208";a="170772009" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 01 Nov 2017 18:13:28 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 1 Nov 2017 18:13:28 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Thu, 2 Nov 2017 09:13:11 +0800 From: "Gao, Liming" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Dong, Eric" Thread-Topic: [patch] BaseTools/VfrCompile: Add check to avoid using NULL pointer Thread-Index: AQHTUx1DoHHVhpRxaE6Sj9zxfo0PJqMAST4Q Date: Thu, 2 Nov 2017 01:13:11 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E176D2D@SHSMSX104.ccr.corp.intel.com> References: <1509546305-10872-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1509546305-10872-1-git-send-email-dandan.bi@intel.com> Accept-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-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] BaseTools/VfrCompile: Add check to avoid using NULL pointer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Nov 2017 01:09:35 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Bi, Dandan > Sent: Wednesday, November 1, 2017 10:25 PM > To: edk2-devel@lists.01.org > Cc: Dong, Eric ; Gao, Liming > Subject: [patch] BaseTools/VfrCompile: Add check to avoid using NULL poin= ter >=20 > Question value are stored in one specified storage, but the Data type > of the storage or the field in the Data type may be NULL sometime, > so we need to add check before using these related pointers. > Here list some NULL cases: > (1)For an efivastore which doesn't specify a data structure or a > data type(UINT8,UINT16...)as the storage, just has VarName and > VarSize instead, we can not get its data type before parsing > its VarSize. >=20 > (2)For efivastore which just specifies the data type(UINT8,UINT16...) > not a structure as the storage,this data type doesn't have sub-fields. >=20 > Cc: Eric Dong > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Dandan Bi > --- > BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/= Source/C/VfrCompile/VfrUtilityLib.cpp > index b00a926..0fe14b0 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp > +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp > @@ -613,13 +613,17 @@ CVfrVarDataTypeDB::DataTypeHasBitField ( > { > SVfrDataType *pType =3D NULL; > SVfrDataField *pTmp; >=20 > GetDataType (TypeName, &pType); > + > + if (pType =3D=3D NULL){ > + return FALSE; > + } > for (pTmp =3D pType->mMembers; pTmp!=3D NULL; pTmp =3D pTmp->mNext) { > if (pTmp->mIsBitField) { > - return TRUE; > + return TRUE; > } > } > return FALSE; > } >=20 > @@ -646,11 +650,11 @@ CVfrVarDataTypeDB::IsThisBitField ( > while (*VarStr !=3D '\0') { > CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx= ), VFR_RETURN_SUCCESS); > CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_S= UCCESS); > pType =3D pField->mFieldType; > } > - if (pField->mIsBitField) { > + if (pField !=3D NULL && pField->mIsBitField) { > return TRUE; > } else { > return FALSE; > } > } > -- > 1.9.5.msysgit.1