]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the issue that the variable Unicode string may be not aligned on 16-bit boundary...
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 16 Mar 2007 09:12:20 +0000 (09:12 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 16 Mar 2007 09:12:20 +0000 (09:12 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2482 6f19259b-4bc3-4df7-8a09-765794883524

EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.msa
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariableIpf.msa
EdkModulePkg/Universal/Variable/Pei/Variable.c
EdkModulePkg/Universal/Variable/Pei/Variable.msa
EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c
EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa
EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa

index accf5d799c872ba4bcb87e67c25a9b436693f10a..acc41218792404856b70254c46483e034e289241 100644 (file)
@@ -58,44 +58,6 @@ ReleaseLockOnlyAtBootTime (
   }\r
 }\r
 \r
-\r
-STATIC\r
-UINT32\r
-EFIAPI\r
-ArrayLength (\r
-  IN CHAR16 *String\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Determine the length of null terminated char16 array.\r
-\r
-Arguments:\r
-\r
-  String    Null-terminated CHAR16 array pointer.\r
-\r
-Returns:\r
-\r
-  UINT32    Number of bytes in the string, including the double NULL at the end;\r
-\r
---*/\r
-{\r
-  UINT32  Count;\r
-\r
-  if (NULL == String) {\r
-    return 0;\r
-  }\r
-\r
-  Count = 0;\r
-\r
-  while (0 != String[Count]) {\r
-    Count++;\r
-  }\r
-\r
-  return (Count * 2) + 2;\r
-}\r
-\r
 STATIC\r
 UINT8 *\r
 EFIAPI\r
@@ -269,7 +231,7 @@ Returns:
             return EFI_SUCCESS;\r
           } else {\r
             if (CompareGuid (VendorGuid, &Variable[Index]->VendorGuid)) {\r
-              if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), ArrayLength (VariableName))) {\r
+              if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), Variable[Index]->NameSize)) {\r
                 PtrTrack->CurrPtr   = Variable[Index];\r
                 PtrTrack->Volatile  = (BOOLEAN) Index;\r
                 return EFI_SUCCESS;\r
@@ -529,7 +491,7 @@ Returns:
     //\r
     Status = EFI_WRITE_PROTECTED;\r
     goto Done;\r
-  } else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {\r
+  } else if (sizeof (VARIABLE_HEADER) + (StrSize (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {\r
     //\r
     //  The size of the VariableName, including the Unicode Null in bytes plus\r
     //  the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.\r
@@ -590,7 +552,7 @@ Returns:
     // Create a new variable and copy the data.\r
     //\r
     VarNameOffset = sizeof (VARIABLE_HEADER);\r
-    VarNameSize   = ArrayLength (VariableName);\r
+    VarNameSize   = StrSize (VariableName);\r
     VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize);\r
     VarSize       = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize);\r
 \r
index 7acd1ba81954e5622f72c31d9f8d4f808bb9ae31..1fbf8da410e44d6ec371169f2d35bee33b7331be 100644 (file)
@@ -43,6 +43,9 @@
     <LibraryClass Usage="ALWAYS_CONSUMED">\r
       <Keyword>UefiLib</Keyword>\r
     </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
   </LibraryClassDefinitions>\r
   <SourceFiles>\r
     <Filename>Variable.h</Filename>\r
index 9264ffacda8b861fc4d169e57a2571c52657f81f..e0f66f981f27e5315ab88ff4835da7f6a8a83632 100644 (file)
@@ -46,6 +46,9 @@
     <LibraryClass Usage="ALWAYS_CONSUMED">\r
       <Keyword>UefiLib</Keyword>\r
     </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
   </LibraryClassDefinitions>\r
   <SourceFiles>\r
     <Filename>Variable.h</Filename>\r
index e2f3c4bdddf6d00bd310e90aea7a17bb5a80877d..33772f8513ddb1ff3564deeee9d0ab7866090033 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
 All rights reserved. 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
@@ -209,7 +209,7 @@ Returns:
         (((INT32 *) VendorGuid)[2] == ((INT32 *) &Variable->VendorGuid)[2]) &&\r
         (((INT32 *) VendorGuid)[3] == ((INT32 *) &Variable->VendorGuid)[3])\r
         ) {\r
-      if (!StrCmp (VariableName, GET_VARIABLE_NAME_PTR (Variable))) {\r
+      if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable), Variable->NameSize)) {\r
         PtrTrack->CurrPtr = Variable;\r
         return EFI_SUCCESS;\r
       }\r
index 6bb518a1db19a03e541979cedbb05362837ec5dc..a1a3c93f55afe802b182d2cfc8b2e40d29369d9d 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
+<?xml version="1.0" encoding="UTF-8"?>\r
 <ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
   <MsaHeader>\r
     <ModuleName>PeiVariable</ModuleName>\r
@@ -8,11 +8,11 @@
     <Abstract>Component description file for PeiVariable module.</Abstract>\r
     <Description>Framework PEIM to provide the Variable functionality.</Description>\r
     <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
-    <License>All rights reserved. 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
-      http://opensource.org/licenses/bsd-license.php\r
-      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    <License>All rights reserved. This program and the accompanying materials
+      are licensed and made available under the terms and conditions of the BSD License
+      which accompanies this distribution.  The full text of the license may be found at
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
     <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
   </MsaHeader>\r
@@ -37,6 +37,9 @@
     <LibraryClass Usage="ALWAYS_CONSUMED">\r
       <Keyword>PcdLib</Keyword>\r
     </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
   </LibraryClassDefinitions>\r
   <SourceFiles>\r
     <Filename>Variable.h</Filename>\r
@@ -67,7 +70,7 @@
     <PcdEntry PcdItemType="DYNAMIC">\r
       <C_Name>PcdFlashNvStorageVariableBase</C_Name>\r
       <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
-      <HelpText>The driver gets the Variable store base address from this PCD.  This base address point to\r
+      <HelpText>The driver gets the Variable store base address from this PCD.  This base address point to
         an EFI_FIRMWARE_VOLUMN_HEADER struct.</HelpText>\r
     </PcdEntry>\r
   </PcdCoded>\r
index da711ebe4843e9dda94d4b0826bd009728045a47..a3992f7ebdfed988e802ec7b317936fac9b09a4c 100644 (file)
@@ -59,43 +59,6 @@ ReleaseLockOnlyAtBootTime (
   }\r
 }\r
 \r
-STATIC\r
-UINT32\r
-EFIAPI\r
-ArrayLength (\r
-  IN CHAR16 *String\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Determine the length of null terminated char16 array.\r
-\r
-Arguments:\r
-\r
-  String    Null-terminated CHAR16 array pointer.\r
-\r
-Returns:\r
-\r
-  UINT32    Number of bytes in the string, including the double NULL at the end;\r
-\r
---*/\r
-{\r
-  UINT32  Count;\r
-\r
-  if (NULL == String) {\r
-    return 0;\r
-  }\r
-\r
-  Count = 0;\r
-\r
-  while (0 != String[Count]) {\r
-    Count++;\r
-  }\r
-\r
-  return (Count * 2) + 2;\r
-}\r
-\r
 STATIC\r
 BOOLEAN\r
 EFIAPI\r
@@ -600,7 +563,7 @@ Returns:
             return EFI_SUCCESS;\r
           } else {\r
             if (CompareGuid (VendorGuid, &Variable[Index]->VendorGuid)) {\r
-              if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), ArrayLength (VariableName))) {\r
+              if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), Variable[Index]->NameSize)) {\r
                 PtrTrack->CurrPtr   = Variable[Index];\r
                 PtrTrack->Volatile  = (BOOLEAN) Index;\r
                 return EFI_SUCCESS;\r
@@ -876,7 +839,7 @@ Returns:
     //\r
     Status = EFI_WRITE_PROTECTED;\r
     goto Done;\r
-  } else if (sizeof (VARIABLE_HEADER) + ArrayLength (VariableName) + DataSize > MAX_VARIABLE_SIZE) {\r
+  } else if (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > MAX_VARIABLE_SIZE) {\r
     //\r
     //  The size of the VariableName, including the Unicode Null in bytes plus\r
     //  the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.\r
@@ -985,7 +948,7 @@ Returns:
     //\r
     NextVariable->Reserved  = 0;\r
     VarNameOffset           = sizeof (VARIABLE_HEADER);\r
-    VarNameSize             = ArrayLength (VariableName);\r
+    VarNameSize             = StrSize (VariableName);\r
     CopyMem (\r
       (UINT8 *) ((UINTN) NextVariable + VarNameOffset),\r
       VariableName,\r
index 227d8a1344451d3c71ddba4c069fadd872889b80..d1e6f3bb931968bdb302f65c0aff210a44d204bf 100644 (file)
@@ -49,6 +49,9 @@
     <LibraryClass Usage="ALWAYS_CONSUMED">\r
       <Keyword>UefiLib</Keyword>\r
     </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
   </LibraryClassDefinitions>\r
   <SourceFiles>\r
     <Filename>Variable.h</Filename>\r
index cbc60df38ebf8b70776b58fe86f512ecf1c5b6e8..11ca3086ba5da961ac0090c3576c7a446ff1c7bb 100644 (file)
@@ -52,6 +52,9 @@
     <LibraryClass Usage="ALWAYS_CONSUMED">\r
       <Keyword>UefiLib</Keyword>\r
     </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
   </LibraryClassDefinitions>\r
   <SourceFiles>\r
     <Filename>Variable.h</Filename>\r