public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Bi, Dandan" <dandan.bi@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Dong, Eric" <eric.dong@intel.com>
Subject: Re: [patch] BaseTools/VfrCompile: Add check to avoid using NULL pointer
Date: Thu, 2 Nov 2017 01:13:11 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E176D2D@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1509546305-10872-1-git-send-email-dandan.bi@intel.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Bi, Dandan
> Sent: Wednesday, November 1, 2017 10:25 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [patch] BaseTools/VfrCompile: Add check to avoid using NULL pointer
> 
> 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.
> 
> (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.
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> 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  = NULL;
>    SVfrDataField       *pTmp;
> 
>    GetDataType (TypeName, &pType);
> +
> +  if (pType == NULL){
> +    return FALSE;
> +  }
>    for (pTmp = pType->mMembers; pTmp!= NULL; pTmp = pTmp->mNext) {
>      if (pTmp->mIsBitField) {
> -       return TRUE;
> +      return TRUE;
>      }
>    }
>    return FALSE;
>  }
> 
> @@ -646,11 +650,11 @@ CVfrVarDataTypeDB::IsThisBitField (
>    while (*VarStr != '\0') {
>      CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx), VFR_RETURN_SUCCESS);
>      CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUCCESS);
>      pType  = pField->mFieldType;
>    }
> -  if (pField->mIsBitField) {
> +  if (pField != NULL && pField->mIsBitField) {
>      return TRUE;
>    } else {
>      return FALSE;
>    }
>  }
> --
> 1.9.5.msysgit.1



      reply	other threads:[~2017-11-02  1:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 14:25 [patch] BaseTools/VfrCompile: Add check to avoid using NULL pointer Dandan Bi
2017-11-02  1:13 ` Gao, Liming [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E176D2D@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox