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: Liming Gao <liming....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zh...@intel.com>
---
 .../BaseUefiTianoCustomDecompressLib.c               | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
 
b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
index 970795b1da..a7ff94920e 100644
--- 
a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
+++ 
b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
@@ -213,12 +213,12 @@ MakeTable (
 
     if (Len <= TableBits) {
 
-      for (Index = Start[Len]; Index < NextCode; Index++) {
-        if (Index >= MaxTableLength) {
-          return (UINT16) BAD_TABLE;
-        }
-        Table[Index] = Char;
-      }
+       if (Start[Len] + NextCode > MaxTableLength) {
+         return (UINT16) BAD_TABLE;
+       }
+       for (Index = Start[Len]; Index < NextCode; Index++) {
+         Table[Index] = Char;
+       }
 
     } else {
 
-- 
2.18.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to