summaryrefslogtreecommitdiffstats
path: root/CryptoPkg
diff options
context:
space:
mode:
authorLong Qin <qin.long@intel.com>2018-01-22 14:27:53 +0800
committerLong Qin <qin.long@intel.com>2018-01-22 14:33:08 +0800
commit34fa6fe30717b409abad12d58d8f728fa99b1c21 (patch)
treeb3052ea0f584b82a23227a9d3d2376e7f0a7a064 /CryptoPkg
parentfe5adb77df646808f471a62cc91a672d9d4ef32c (diff)
downloadedk2-34fa6fe30717b409abad12d58d8f728fa99b1c21.tar.gz
edk2-34fa6fe30717b409abad12d58d8f728fa99b1c21.tar.bz2
edk2-34fa6fe30717b409abad12d58d8f728fa99b1c21.zip
CryptoPkg/BaseCryptLib: Add error handling for time() wrapper
In time() wrapper implementation, the gRT->GetTime() call may be not available. This patch adds the extra error handling to avoid the potential dead loop. Cc: Star Zeng <star.zeng@intel.com> Cc: Ting Ye <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> (cherry picked from commit ab187ae25a7cc230af32a540ca14737bd93d9665)
Diffstat (limited to 'CryptoPkg')
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
index 581b8fb028..cdf3b60b9f 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
@@ -2,7 +2,7 @@
C Run-Time Libraries (CRT) Time Management Routines Wrapper Implementation
for OpenSSL-based Cryptographic Library (used in DXE & RUNTIME).
-Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -72,14 +72,18 @@ UINTN CumulativeDays[2][14] = {
// )
time_t time (time_t *timer)
{
- EFI_TIME Time;
- time_t CalTime;
- UINTN Year;
+ EFI_STATUS Status;
+ EFI_TIME Time;
+ time_t CalTime;
+ UINTN Year;
//
// Get the current time and date information
//
- gRT->GetTime (&Time, NULL);
+ Status = gRT->GetTime (&Time, NULL);
+ if (EFI_ERROR (Status) || (Time.Year < 1970)) {
+ return 0;
+ }
//
// Years Handling