From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from huawei.com (huawei.com [45.249.212.32]) by mx.groups.io with SMTP id smtpd.web10.4478.1600829931643873369 for ; Tue, 22 Sep 2020 19:58:52 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.32, mailfrom: xiewenyi2@huawei.com) Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 27D09CEF91A0C77F1020; Wed, 23 Sep 2020 10:58:47 +0800 (CST) Received: from [10.174.153.72] (10.174.153.72) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Wed, 23 Sep 2020 10:58:38 +0800 Subject: Re: [edk2-devel] [PATCH EDK2 v1 1/1] EmulatorPkg/host: fix overflow in Mult To: "Ni, Ray" , "devel@edk2.groups.io" , "Justen, Jordan L" , "afish@apple.com" CC: "songdongkuang@huawei.com" References: <1598957888-128729-1-git-send-email-xiewenyi2@huawei.com> <1598957888-128729-2-git-send-email-xiewenyi2@huawei.com> From: "wenyi,xie" Message-ID: <5407ea33-49fa-1920-ceb9-abcd832ed802@huawei.com> Date: Wed, 23 Sep 2020 10:58:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.0.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.174.153.72] X-CFilter-Loop: Reflected Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit OK, Thanks. Regards Wenyi On 2020/9/23 10:48, Ni, Ray wrote: > Reviewed-by: Ray Ni > > Pull request was created: https://github.com/tianocore/edk2/pull/951 > > If you see any failures, please send updated patch to fix. > >> -----Original Message----- >> From: devel@edk2.groups.io On Behalf Of wenyi,xie >> via groups.io >> Sent: Tuesday, September 22, 2020 11:43 AM >> To: devel@edk2.groups.io; Justen, Jordan L ; >> afish@apple.com; Ni, Ray >> Cc: songdongkuang@huawei.com >> Subject: Re: [edk2-devel] [PATCH EDK2 v1 1/1] EmulatorPkg/host: fix overflow >> in Mult >> >> Hi all, >> >> Please review this patch when you're free, thanks. >> >> Regards >> Wenyi >> >> On 2020/9/1 18:58, Wenyi Xie wrote: >>> 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 >>> Cc: Andrew Fish >>> Cc: Ray Ni >>> Signed-off-by: Wenyi Xie >>> --- >>> EmulatorPkg/Win/Host/WinHost.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/EmulatorPkg/Win/Host/WinHost.c >> b/EmulatorPkg/Win/Host/WinHost.c >>> index 0838c56ddea8..876cb8d4be8b 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 >>> >> >> >> >> >