]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/C/Common: Improve performance of boundary validation
authorShenglei Zhang <shenglei.zhang@intel.com>
Mon, 25 Feb 2019 05:53:37 +0000 (13:53 +0800)
committerLiming Gao <liming.gao@intel.com>
Wed, 27 Mar 2019 12:11:22 +0000 (20:11 +0800)
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>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/C/Common/Decompress.c

index 0e9ba0a9826a196a7db0547ca8f721e353062edf..e9ac1d58b31e42c3cbbec26598c684d928c75ae4 100644 (file)
@@ -254,10 +254,11 @@ Returns:
 \r
     if (Len <= TableBits) {\r
 \r
+      if (Start[Len] >= NextCode || NextCode > MaxTableLength){\r
+        return (UINT16) BAD_TABLE;\r
+      }\r
+\r
       for (Index = Start[Len]; Index < NextCode; Index++) {\r
-        if (Index >= MaxTableLength) {\r
-          return (UINT16) BAD_TABLE;\r
-        }\r
         Table[Index] = Char;\r
       }\r
 \r