]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg: Fix integer overflow
authorYuan Yu <yuanyu@google.com>
Wed, 28 Sep 2022 07:49:24 +0000 (15:49 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 10 Oct 2022 00:58:26 +0000 (00:58 +0000)
SECSPERDAY is 86400 which exceeds the limit of a UINT16 which is 65536.
Therefore DayRemainder cannot use UINT16. This patch makes it UINT32.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Signed-off-by: Yuan Yu <yuanyu@google.com>
Reviewed-by: Ard Biesheuvel <ardb+tianocore@kernel.org>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c

index 7d28446d4b5c6673b35fee3282612843431502fc..bf8a5325817f938f89cfdf42180b8b0678f4edb6 100644 (file)
@@ -118,7 +118,7 @@ gmtime (
 {\r
   struct tm  *GmTime;\r
   UINT16     DayNo;\r
-  UINT16     DayRemainder;\r
+  UINT32     DayRemainder;\r
   time_t     Year;\r
   time_t     YearNo;\r
   UINT16     TotalDays;\r
@@ -136,7 +136,7 @@ gmtime (
   ZeroMem ((VOID *)GmTime, (UINTN)sizeof (struct tm));\r
 \r
   DayNo        = (UINT16)(*timer / SECSPERDAY);\r
-  DayRemainder = (UINT16)(*timer % SECSPERDAY);\r
+  DayRemainder = (UINT32)(*timer % SECSPERDAY);\r
 \r
   GmTime->tm_sec  = (int)(DayRemainder % SECSPERMIN);\r
   GmTime->tm_min  = (int)((DayRemainder % SECSPERHOUR) / SECSPERMIN);\r