Ok, got it.

Reviewed-by: Star Zeng <star.z...@intel.com>

Thanks,
Star
-----Original Message-----
From: Long, Qin 
Sent: Friday, January 19, 2018 3:12 PM
To: Zeng, Star <star.z...@intel.com>; edk2-devel@lists.01.org
Cc: Ye, Ting <ting...@intel.com>
Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() 
wrapper

It's legal to continue the calculation about the seconds elapsed since 
1970.01.01 00:00:00.


-----Original Message-----
From: Zeng, Star 
Sent: Friday, January 19, 2018 3:10 PM
To: Long, Qin <qin.l...@intel.com>; edk2-devel@lists.01.org
Cc: Ye, Ting <ting...@intel.com>; Zeng, Star <star.z...@intel.com>
Subject: RE: [PATCH] CryptoPkg/BaseCryptLib: Add error handling for time() 
wrapper

What will happen if Time.Year == 1970? :)

Thanks,
Star
-----Original Message-----
From: Long, Qin
Sent: Friday, January 19, 2018 3:05 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.z...@intel.com>; Ye, Ting <ting...@intel.com>; Long, Qin 
<qin.l...@intel.com>
Subject: [PATCH] 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.z...@intel.com>
Cc: Ting Ye <ting...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.l...@intel.com>
---
 CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c 
b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
index 581b8fb028..95e0419640 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
@@ -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
--
2.15.1.windows.2

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to