summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2007-03-16 09:12:20 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2007-03-16 09:12:20 +0000
commitbb60dd97af4e377073e2c6700830897405f232bd (patch)
tree7253e49b0ea0dad95c693eafd33d7295ed816f9e /EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
parent7af45bf1f0b989e932cd36d6ab729d9878bbc982 (diff)
downloadedk2-platforms-bb60dd97af4e377073e2c6700830897405f232bd.tar.xz
Fix the issue that the variable Unicode string may be not aligned on 16-bit boundary in flash (it dependent on ALIGNMENT macro in EdkModulePkg\Universal\Variable\Pei\x64\VarMachine.h). The unalignment Unicode string will lead assert of StrCmp, StrCopy, StrLen function in Mde library.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2482 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c')
-rw-r--r--EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c44
1 files changed, 3 insertions, 41 deletions
diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
index accf5d799c..acc4121879 100644
--- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
+++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
@@ -58,44 +58,6 @@ ReleaseLockOnlyAtBootTime (
}
}
-
-STATIC
-UINT32
-EFIAPI
-ArrayLength (
- IN CHAR16 *String
- )
-/*++
-
-Routine Description:
-
- Determine the length of null terminated char16 array.
-
-Arguments:
-
- String Null-terminated CHAR16 array pointer.
-
-Returns:
-
- UINT32 Number of bytes in the string, including the double NULL at the end;
-
---*/
-{
- UINT32 Count;
-
- if (NULL == String) {
- return 0;
- }
-
- Count = 0;
-
- while (0 != String[Count]) {
- Count++;
- }
-
- return (Count * 2) + 2;
-}
-
STATIC
UINT8 *
EFIAPI
@@ -269,7 +231,7 @@ Returns:
return EFI_SUCCESS;
} else {
if (CompareGuid (VendorGuid, &Variable[Index]->VendorGuid)) {
- if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), ArrayLength (VariableName))) {
+ if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), Variable[Index]->NameSize)) {
PtrTrack->CurrPtr = Variable[Index];
PtrTrack->Volatile = (BOOLEAN) Index;
return EFI_SUCCESS;
@@ -529,7 +491,7 @@ Returns:
//
Status = EFI_WRITE_PROTECTED;
goto Done;
- } else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {
+ } else if (sizeof (VARIABLE_HEADER) + (StrSize (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {
//
// The size of the VariableName, including the Unicode Null in bytes plus
// the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.
@@ -590,7 +552,7 @@ Returns:
// Create a new variable and copy the data.
//
VarNameOffset = sizeof (VARIABLE_HEADER);
- VarNameSize = ArrayLength (VariableName);
+ VarNameSize = StrSize (VariableName);
VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize);
VarSize = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize);