summaryrefslogtreecommitdiffstats
path: root/EmulatorPkg
diff options
context:
space:
mode:
authorwenyi,xie via groups.io <xiewenyi2=huawei.com@groups.io>2020-09-01 18:58:08 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-09-23 02:53:41 +0000
commitdd5c7e3c5282b084daa5bbf0ec229cec699b2c17 (patch)
tree5422a827ca317dd191f990afa565cd9e5689d5c3 /EmulatorPkg
parent3f3daf89308930e45f82ae67dd2a2d6e030bb091 (diff)
downloadedk2-dd5c7e3c5282b084daa5bbf0ec229cec699b2c17.tar.gz
edk2-dd5c7e3c5282b084daa5bbf0ec229cec699b2c17.tar.bz2
edk2-dd5c7e3c5282b084daa5bbf0ec229cec699b2c17.zip
EmulatorPkg/host: fix overflow in Mult
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2947 When calculating memory regions and store the information in the gSystemMemory in file WinHost.c, the code below will cause overflow, because _wtoi (MemorySizeStr) return an int value and SIZE_1MB is also an int value, if MemorySizeStr is lager for example 2048, then result of multiplication will overflow. for (Index = 0, Done = FALSE; !Done; Index++) { // // Save the size of the memory and make a Unicode filename SystemMemory00 // gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB; Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Andrew Fish <afish@apple.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
Diffstat (limited to 'EmulatorPkg')
-rw-r--r--EmulatorPkg/Win/Host/WinHost.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 0838c56dde..876cb8d4be 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -577,7 +577,7 @@ Returns:
//
// Save the size of the memory and make a Unicode filename SystemMemory00, ...
//
- gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
+ gSystemMemory[Index].Size = ((UINT64)_wtoi (MemorySizeStr)) * ((UINT64)SIZE_1MB);
//
// Find the next region