diff options
author | Hao Wu <hao.a.wu@intel.com> | 2017-03-22 10:08:55 +0800 |
---|---|---|
committer | Guo Mang <mang.guo@intel.com> | 2017-07-12 11:24:16 +0800 |
commit | 40d9f99f42d3af11ff7af63bb70f5ad2819b333f (patch) | |
tree | 54fdacb5c57e6874a8fa3cc297c5e25a2f1610df | |
parent | 74175378710fa7c4a2f0d7a1d742c4e1125a8c5f (diff) | |
download | edk2-platforms-40d9f99f42d3af11ff7af63bb70f5ad2819b333f.tar.xz |
MdeModulePkg/DxeCore: Add ASSERT to ensure no subtract underflow
For function SplitRecord() in file PropertiesTable.c, there is a
potential subtract underflow case for line:
return TotalNewRecordCount - 1;
However, such case will not happen since the logic in function
SplitTable() ensure that when calling SplitRecord(), the variable
'TotalNewRecordCount' will not be zero when performing the subtraction.
It will be handled in the previous if statement:
if (MaxSplitRecordCount == 0) {
CopyMem (NewRecord, OldRecord, DescriptorSize);
return 0;
}
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 1860cb00c18c6f0c58336ea15a63889dabd31d15)
-rw-r--r-- | Core/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Core/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/Core/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c index e7c4a95712..6cf5edcbe5 100644 --- a/Core/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c +++ b/Core/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c @@ -576,6 +576,11 @@ SplitRecord ( TempRecord.NumberOfPages = EfiSizeToPages (PhysicalEnd - PhysicalStart);
} while ((ImageRecord != NULL) && (PhysicalStart < PhysicalEnd));
+ //
+ // The logic in function SplitTable() ensures that TotalNewRecordCount will not be zero if the
+ // code reaches here.
+ //
+ ASSERT (TotalNewRecordCount != 0);
return TotalNewRecordCount - 1;
}
|