summaryrefslogtreecommitdiffstats
path: root/CryptoPkg/Library
diff options
context:
space:
mode:
authorYuan Yu <yuanyu@google.com>2022-09-28 15:49:24 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-10-10 00:58:26 +0000
commit3c9e2f239a38590b4e3a8c1ec2304227f2af0103 (patch)
tree8bd495b5f9bf941cf620f32e9fb235118735fb8f /CryptoPkg/Library
parentde103f1981cfca90dd19296d4b20449a2b93dc26 (diff)
downloadedk2-3c9e2f239a38590b4e3a8c1ec2304227f2af0103.tar.gz
edk2-3c9e2f239a38590b4e3a8c1ec2304227f2af0103.tar.bz2
edk2-3c9e2f239a38590b4e3a8c1ec2304227f2af0103.zip
CryptoPkg: Fix integer overflow
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>
Diffstat (limited to 'CryptoPkg/Library')
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
index 7d28446d4b..bf8a532581 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
@@ -118,7 +118,7 @@ gmtime (
{
struct tm *GmTime;
UINT16 DayNo;
- UINT16 DayRemainder;
+ UINT32 DayRemainder;
time_t Year;
time_t YearNo;
UINT16 TotalDays;
@@ -136,7 +136,7 @@ gmtime (
ZeroMem ((VOID *)GmTime, (UINTN)sizeof (struct tm));
DayNo = (UINT16)(*timer / SECSPERDAY);
- DayRemainder = (UINT16)(*timer % SECSPERDAY);
+ DayRemainder = (UINT32)(*timer % SECSPERDAY);
GmTime->tm_sec = (int)(DayRemainder % SECSPERMIN);
GmTime->tm_min = (int)((DayRemainder % SECSPERHOUR) / SECSPERMIN);