From: "Yuan Yu" <yuanyu@google.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
Jordan Justen <jordan.l.justen@intel.com>,
Laszlo Ersek <lersek@redhat.com>,
Anthony Perard <anthony.perard@citrix.com>,
Julien Grall <julien@xen.org>
Subject: [PATCH v1 1/1] CryptoPkg: Fix integer overflow
Date: Wed, 28 Sep 2022 00:49:24 -0700 [thread overview]
Message-ID: <20220928074924.528583-2-yuanyu@google.com> (raw)
In-Reply-To: <20220928074924.528583-1-yuanyu@google.com>
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>
---
CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
index 7d28446d4b5c..bf8a5325817f 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);
--
2.37.3.998.g577e59143f-goog
next prev parent reply other threads:[~2022-09-28 7:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 7:49 [PATCH v1 0/1] Fix integer overflow in CryptoPkg Yuan Yu
2022-09-28 7:49 ` Yuan Yu [this message]
2022-09-28 9:19 ` [PATCH v1 1/1] CryptoPkg: Fix integer overflow Ard Biesheuvel
2022-10-10 1:11 ` Yao, Jiewen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220928074924.528583-2-yuanyu@google.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox