Add pointer check for NULL before dereference it.
authorsfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 14 Oct 2011 05:19:25 +0000 (05:19 +0000)
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 14 Oct 2011 05:19:25 +0000 (05:19 +0000)
Signed-off-by: sfu5
Reviewed-by: tye
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12537 6f19259b-4bc3-4df7-8a09-765794883524

SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c

index d6c66863512b58e0b65c865c541d3d91ab2a3443..2be925d2366ad84b976f2d62aebf3606aaee288d 100644 (file)
@@ -846,6 +846,7 @@ UpdateVariableCache (
           // If size of data changes, allocate pool and copy data.\r
           //\r
           Entry->Data = AllocatePool (DataSize);\r
+          ASSERT (Entry->Data != NULL);\r
           Entry->DataSize = DataSize;\r
           CopyMem (Entry->Data, Data, DataSize);\r
         }\r
index df8b30a63e5f004c56de81495773bd1f3b2d0acf..0846b2a21b83778d2499354a5c826ef9947ffaeb 100644 (file)
@@ -1591,12 +1591,11 @@ UpdateVariable (
   NextVariable->MonotonicCount  = MonotonicCount;\r
   SetMem (&NextVariable->TimeStamp, sizeof (EFI_TIME), 0);\r
 \r
-  if (((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) && \r
-      ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0)) {\r
-    CopyMem (&NextVariable->TimeStamp, TimeStamp, sizeof (EFI_TIME));\r
-  } else if (\r
-      ((Attributes & EFI_VARIABLE_APPEND_WRITE) != 0) && \r
-      ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0)) {\r
+  if (((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) &&\r
+        TimeStamp != NULL) {\r
+    if ((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) {\r
+      CopyMem (&NextVariable->TimeStamp, TimeStamp, sizeof (EFI_TIME));\r
+    } else {\r
       //\r
       // In the case when the EFI_VARIABLE_APPEND_WRITE attribute is set, only\r
       // when the new TimeStamp value is later than the current timestamp associated\r
@@ -1605,6 +1604,7 @@ UpdateVariable (
       if (CompareTimeStamp (&Variable->CurrPtr->TimeStamp, TimeStamp)) {\r
         CopyMem (&NextVariable->TimeStamp, TimeStamp, sizeof (EFI_TIME));\r
       }\r
+    }\r
   }\r
 \r
   //\r