]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
CryptoPkg/BaseCryptLib: Add error handling for time() wrapper
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / SysCall / TimerWrapper.c
index 581b8fb02809f2bc45f9cf3c65d503d258508c0d..cdf3b60b9f82aa525d48db70ed548f0e5b951095 100644 (file)
@@ -2,7 +2,7 @@
   C Run-Time Libraries (CRT) Time Management Routines Wrapper Implementation\r
   for OpenSSL-based Cryptographic Library (used in DXE & RUNTIME).\r
 \r
-Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -72,14 +72,18 @@ UINTN CumulativeDays[2][14] = {
 //  )\r
 time_t time (time_t *timer)\r
 {\r
-  EFI_TIME  Time;\r
-  time_t    CalTime;\r
-  UINTN     Year;\r
+  EFI_STATUS  Status;\r
+  EFI_TIME    Time;\r
+  time_t      CalTime;\r
+  UINTN       Year;\r
 \r
   //\r
   // Get the current time and date information\r
   //\r
-  gRT->GetTime (&Time, NULL);\r
+  Status = gRT->GetTime (&Time, NULL);\r
+  if (EFI_ERROR (Status) || (Time.Year < 1970)) {\r
+    return 0;\r
+  }\r
 \r
   //\r
   // Years Handling\r