public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chiu, Chasel" <chasel.chiu@intel.com>
To: "Desimone, Nathaniel L" <nathaniel.l.desimone@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Liming Gao <gaoliming@byosoft.com.cn>,
	"Dong, Eric" <eric.dong@intel.com>
Subject: Re: [edk2-platforms] [PATCH V1 1/2] MinPlatformPkg: Add missing bounds checks to CompressLib
Date: Thu, 1 Oct 2020 17:25:10 +0000	[thread overview]
Message-ID: <SN6PR11MB2814D38F825F29DA4EFDDF48E6300@SN6PR11MB2814.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200930001529.2212-2-nathaniel.l.desimone@intel.com>


Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>


> -----Original Message-----
> From: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Sent: Wednesday, September 30, 2020 8:15 AM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Dong, Eric <eric.dong@intel.com>
> Subject: [edk2-platforms] [PATCH V1 1/2] MinPlatformPkg: Add missing bounds
> checks to CompressLib
> 
> Current code only as bounds checks in ASSERT macros.
> They are also needed in release mode where ASSERT is not used.
> 
> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Eric Dong <eric.dong@intel.com>
> ---
>  .../MinPlatformPkg/Library/CompressLib/CompressLib.c   | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c
> b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c
> index 9f93e1ee2d..537eb3b693 100644
> --- a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c
> +++ b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c
> @@ -1002,7 +1002,10 @@ CountTFreq (
>          mTFreq[2]++;
>        }
>      } else {
> -      ASSERT((LoopVar3+2)<(2 * NT - 1));
> +      ASSERT ((LoopVar3 + 2) < (2 * NT - 1));
> +      if ((LoopVar3 + 2) >= (2 * NT - 1)) {
> +        return;
> +      }
>        mTFreq[LoopVar3 + 2]++;
>      }
>    }
> @@ -1101,7 +1104,10 @@ WriteCLen (
>          PutBits (CBIT, Count - 20);
>        }
>      } else {
> -      ASSERT((LoopVar3+2)<NPT);
> +      ASSERT ((LoopVar3 + 2) < NPT);
> +      if ((LoopVar3 + 2) >= NPT) {
> +        return;
> +      }
>        PutBits (mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]);
>      }
>    }
> --
> 2.27.0.windows.1


  reply	other threads:[~2020-10-01 17:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30  0:15 [edk2-platforms] [PATCH V1 0/2] MinPlatformPkg: Minor fixes in CompressLib Nate DeSimone
2020-09-30  0:15 ` [edk2-platforms] [PATCH V1 1/2] MinPlatformPkg: Add missing bounds checks to CompressLib Nate DeSimone
2020-10-01 17:25   ` Chiu, Chasel [this message]
2020-09-30  0:15 ` [edk2-platforms] [PATCH V1 2/2] MinPlatformPkg: Coding style cleanups in CompressLib Nate DeSimone
2020-10-01 17:25   ` Chiu, Chasel

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=SN6PR11MB2814D38F825F29DA4EFDDF48E6300@SN6PR11MB2814.namprd11.prod.outlook.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