]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Refine code to make it more safely.
authorEric Dong <eric.dong@intel.com>
Wed, 25 Jun 2014 06:00:49 +0000 (06:00 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 25 Jun 2014 06:00:49 +0000 (06:00 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15590 6f19259b-4bc3-4df7-8a09-765794883524

SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/AuthService.c

index 9f2bd68299895616b376db3afc61d24da1839a29..0a48ce16287b34ea8deb7cde89cad43a850cccf5 100644 (file)
@@ -770,22 +770,22 @@ AddImageExeInfo (
   //\r
   // Update new item's information.\r
   //\r
-  WriteUnaligned32 ((UINT32 *) &ImageExeInfoEntry->Action, Action);\r
-  WriteUnaligned32 ((UINT32 *) &ImageExeInfoEntry->InfoSize, (UINT32) NewImageExeInfoEntrySize);\r
+  WriteUnaligned32 ((UINT32 *) ImageExeInfoEntry, Action);\r
+  WriteUnaligned32 ((UINT32 *) ((UINT8 *) ImageExeInfoEntry + sizeof (EFI_IMAGE_EXECUTION_ACTION)), (UINT32) NewImageExeInfoEntrySize);\r
 \r
   if (Name != NULL) {\r
-    CopyMem ((UINT8 *) &ImageExeInfoEntry->InfoSize + sizeof (UINT32), Name, NameStringLen);\r
+    CopyMem ((UINT8 *) ImageExeInfoEntry + sizeof (EFI_IMAGE_EXECUTION_ACTION) + sizeof (UINT32), Name, NameStringLen);\r
   } else {\r
-    ZeroMem ((UINT8 *) &ImageExeInfoEntry->InfoSize + sizeof (UINT32), sizeof (CHAR16));\r
+    ZeroMem ((UINT8 *) ImageExeInfoEntry + sizeof (EFI_IMAGE_EXECUTION_ACTION) + sizeof (UINT32), sizeof (CHAR16));\r
   }\r
   CopyMem (\r
-    (UINT8 *) &ImageExeInfoEntry->InfoSize + sizeof (UINT32) + NameStringLen,\r
+    (UINT8 *) ImageExeInfoEntry + sizeof (EFI_IMAGE_EXECUTION_ACTION) + sizeof (UINT32) + NameStringLen,\r
     DevicePath,\r
     DevicePathSize\r
     );\r
   if (Signature != NULL) {\r
     CopyMem (\r
-      (UINT8 *) &ImageExeInfoEntry->InfoSize + sizeof (UINT32) + NameStringLen + DevicePathSize,\r
+      (UINT8 *) ImageExeInfoEntry + sizeof (EFI_IMAGE_EXECUTION_ACTION) + sizeof (UINT32) + NameStringLen + DevicePathSize,\r
       Signature,\r
       SignatureSize\r
       );\r
index 38f462628ad71872772aafac8c6e23cd295e6758..45d5cfe3c655769d15ceef081e863f6d4d686185 100644 (file)
@@ -2,7 +2,7 @@
   Implement authentication services for the authenticated variable\r
   service in UEFI2.2.\r
 \r
-Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2014, 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
@@ -48,6 +48,8 @@ AutenticatedVariableServiceInitialize (
   VARIABLE_HEADER         VariableHeader;\r
   BOOLEAN                 Valid;\r
 \r
+  ZeroMem (&VariableHeader, sizeof (VARIABLE_HEADER));\r
+\r
   mVariableModuleGlobal->AuthenticatedVariableGuid[Physical] = &gEfiAuthenticatedVariableGuid;\r
   mVariableModuleGlobal->CertRsa2048Sha256Guid[Physical]     = &gEfiCertRsa2048Sha256Guid;\r
   mVariableModuleGlobal->ImageSecurityDatabaseGuid[Physical] = &gEfiImageSecurityDatabaseGuid;\r
@@ -484,6 +486,7 @@ ProcessVarWithPk (
   BOOLEAN                     Valid;\r
 \r
   OldPkList = NULL;\r
+  ZeroMem (&VariableHeader, sizeof (VARIABLE_HEADER));\r
 \r
   if ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
     //\r
@@ -623,6 +626,7 @@ ProcessVarWithKek (
   BOOLEAN                         Valid;\r
 \r
   KekList = NULL;\r
+  ZeroMem (&VariableHeader, sizeof (VARIABLE_HEADER));\r
 \r
   if (mPlatformMode == USER_MODE) {\r
     if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) == 0) {\r