summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/BaseUefiDecompressLib
diff options
context:
space:
mode:
authorShenglei Zhang <shenglei.zhang@intel.com>2019-02-25 13:55:54 +0800
committerLiming Gao <liming.gao@intel.com>2019-03-27 20:11:22 +0800
commit8028f03032182f2c72e7699e1d14322bb5586581 (patch)
tree6def8b75cd0a34e315824b65e311c19fb979c7b8 /MdePkg/Library/BaseUefiDecompressLib
parent55756c88aec9d3269d8544746907838ba921e90b (diff)
downloadedk2-8028f03032182f2c72e7699e1d14322bb5586581.tar.gz
edk2-8028f03032182f2c72e7699e1d14322bb5586581.tar.bz2
edk2-8028f03032182f2c72e7699e1d14322bb5586581.zip
MdePkg/BaseUefiDecompressLib: Improve performance of boundary validation
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: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@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>
Diffstat (limited to 'MdePkg/Library/BaseUefiDecompressLib')
-rw-r--r--MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
index c1e8c5581a..3d5b7a737a 100644
--- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
+++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
@@ -222,10 +222,11 @@ MakeTable (
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;
}