Revision: 18227
          http://sourceforge.net/p/edk2/code/18227
Author:   jyao1
Date:     2015-08-17 05:48:30 +0000 (Mon, 17 Aug 2015)
Log Message:
-----------
Add context check and init in BaseCrypto2Hash().

Follow UEFI specification to add context check and init in BaseCrypto2Hash(), 
so that other function can get proper status on hash operation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <[email protected]>
Reviewed-by: "Zhang, Chao B" <[email protected]>

Modified Paths:
--------------
    trunk/edk2/SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c

Modified: trunk/edk2/SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c
===================================================================
--- trunk/edk2/SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c      2015-08-17 
02:50:26 UTC (rev 18226)
+++ trunk/edk2/SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c      2015-08-17 
05:48:30 UTC (rev 18227)
@@ -358,6 +358,7 @@
   UINTN                    CtxSize;
   BOOLEAN                  Ret;
   EFI_STATUS               Status;
+  HASH2_INSTANCE_DATA      *Instance;
 
   Status = EFI_SUCCESS;
 
@@ -373,6 +374,13 @@
   if (HashInfo == NULL) {
     return EFI_UNSUPPORTED;
   }
+  
+  Instance = HASH2_INSTANCE_DATA_FROM_THIS(This);
+  if (Instance->HashContext != NULL) {
+    FreePool (Instance->HashContext);
+  }
+  Instance->HashInfoContext = NULL;
+  Instance->HashContext = NULL;
 
   //
   // Start hash sequence
@@ -392,6 +400,12 @@
     goto Done;
   }
 
+  //
+  // Setup the context
+  //
+  Instance->HashContext = HashCtx;
+  Instance->HashInfoContext = HashInfo;
+
   Ret = HashInfo->Update (HashCtx, Message, MessageSize);
   if (!Ret) {
     Status = EFI_OUT_OF_RESOURCES;
@@ -404,7 +418,12 @@
     goto Done;
   }
 Done:
+  //
+  // Cleanup the context
+  //
   FreePool (HashCtx);
+  Instance->HashInfoContext = NULL;
+  Instance->HashContext = NULL;
   return Status;
 }
 


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to