public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: shenglei <shenglei.zhang@intel.com>
To: edk2-devel@lists.01.org
Cc: Shenglei Zhang <shenglei.zhang@intel.com>,
	Bob Feng <bob.c.feng@intel.com>,
	Liming Gao <liming.gao@intel.com>,
	Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v2 1/3] BaseTools/TianoCompress: Improve performance of boundary validation
Date: Thu, 21 Mar 2019 14:31:47 +0800	[thread overview]
Message-ID: <20190321063149.13260-2-shenglei.zhang@intel.com> (raw)
In-Reply-To: <20190321063149.13260-1-shenglei.zhang@intel.com>

From: Shenglei Zhang <shenglei.zhang@intel.com>

The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 BaseTools/Source/C/TianoCompress/TianoCompress.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index 29b11c597f..ae88074360 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -2281,10 +2281,11 @@ Returns:
 
     if (Len <= TableBits) {
 
+      if (Start[Len] >= NextCode || NextCode > MaxTableLength){
+        return (UINT16) BAD_TABLE;
+      }
+
       for (Index = Start[Len]; Index < NextCode; Index++) {
-        if (Index >= MaxTableLength) {
-          return (UINT16) BAD_TABLE;
-        }
         Table[Index] = Char;
       }
 
-- 
2.18.0.windows.1



  reply	other threads:[~2019-03-21  6:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21  6:31 [PATCH v2 0/3] Improve performance of boundary validation in MakeTable() shenglei
2019-03-21  6:31 ` shenglei [this message]
2019-03-21  6:31 ` [PATCH v2 2/3] BaseTools/C/Common: Improve performance of boundary validation shenglei
2019-03-21  6:31 ` [PATCH v2 3/3] MdePkg/BaseUefiDecompressLib: " shenglei
2019-03-22  6:34 ` [PATCH v2 0/3] Improve performance of boundary validation in MakeTable() Gao, Liming

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=20190321063149.13260-2-shenglei.zhang@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