]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.c
pointer verification (not NULL) and buffer overrun fixes.
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / SmbiosView / EventLogInfo.c
index f0a9d54b7397a2675199d00d2183dd27688673d3..a1e14678f34271cbe3bb19d02e9977a421608e4c 100644 (file)
@@ -340,55 +340,56 @@ DisplaySysEventLogData (
   //\r
   Offset  = 0;\r
   Log     = (LOG_RECORD_FORMAT *) LogData;\r
-  while (Log->Type != END_OF_LOG && Offset < LogAreaLength) {\r
+  while (Log != NULL && Log->Type != END_OF_LOG && Offset < LogAreaLength) {\r
     //\r
     // Get a Event Log Record\r
     //\r
     Log = (LOG_RECORD_FORMAT *) (LogData + Offset);\r
 \r
-    //\r
-    // Display Event Log Record Information\r
-    //\r
-    DisplaySELVarDataFormatType (Log->Type, SHOW_DETAIL);\r
-    DisplaySELLogHeaderLen (Log->Length, SHOW_DETAIL);\r
-\r
-    Offset += Log->Length;\r
-\r
-    //\r
-    // Display Log Header Date/Time Fields\r
-    // These fields contain the BCD representation of the date and time\r
-    // (as read from CMOS) of the occurrence of the event\r
-    // So Print as hex and represent decimal\r
-    //\r
-    ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle);\r
-    if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) {\r
-      Print (L"19");\r
-    } else if (Log != NULL && Log->Year <= 79) {\r
-      Print (L"20");\r
-    } else {\r
-      ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle);\r
-      continue;\r
+    if (Log != NULL) {\r
+      //\r
+      // Display Event Log Record Information\r
+      //\r
+      DisplaySELVarDataFormatType (Log->Type, SHOW_DETAIL);\r
+      DisplaySELLogHeaderLen (Log->Length, SHOW_DETAIL);\r
+\r
+      Offset += Log->Length;\r
+      //\r
+      // Display Log Header Date/Time Fields\r
+      // These fields contain the BCD representation of the date and time\r
+      // (as read from CMOS) of the occurrence of the event\r
+      // So Print as hex and represent decimal\r
+      //\r
+      ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle);\r
+      if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) {\r
+        Print (L"19");\r
+      } else if (Log != NULL && Log->Year <= 79) {\r
+        Print (L"20");\r
+      } else {\r
+        ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle);\r
+        continue;\r
+      }\r
+\r
+      ShellPrintHiiEx(-1,-1,NULL,\r
+        STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS),\r
+        gShellDebug1HiiHandle,\r
+        Log->Year,\r
+        Log->Month,\r
+        Log->Day,\r
+        Log->Hour,\r
+        Log->Minute,\r
+        Log->Second\r
+       );\r
+\r
+      //\r
+      // Display Variable Data Format\r
+      //\r
+      if (Log->Length <= (sizeof (LOG_RECORD_FORMAT) - 1)) {\r
+        continue;\r
+      }\r
+\r
+      ElVdfType = Log->LogVariableData[0];\r
+      DisplayElVdfInfo (ElVdfType, Log->LogVariableData);\r
     }\r
-\r
-    ShellPrintHiiEx(-1,-1,NULL,\r
-      STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS),\r
-      gShellDebug1HiiHandle,\r
-      Log->Year,\r
-      Log->Month,\r
-      Log->Day,\r
-      Log->Hour,\r
-      Log->Minute,\r
-      Log->Second\r
-     );\r
-\r
-    //\r
-    // Display Variable Data Format\r
-    //\r
-    if (Log->Length <= (sizeof (LOG_RECORD_FORMAT) - 1)) {\r
-      continue;\r
-    }\r
-\r
-    ElVdfType = Log->LogVariableData[0];\r
-    DisplayElVdfInfo (ElVdfType, Log->LogVariableData);\r
   }\r
 }\r