summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-31 06:10:04 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-31 06:10:04 +0000
commit1778a0a4c7e1fa4589d07679660ed88b0c69931a (patch)
tree7c8a1e0de338f8404d58f2d87cfc28f3ca91d87e
parente0b34c57bce04867a36be1fc0057ee75c5c25ae4 (diff)
downloadedk2-1778a0a4c7e1fa4589d07679660ed88b0c69931a.tar.gz
Sync patches r13324 r13362, r13363 and r13366 from main trunk.
1. Clean ParentHandle field when image is loaded directly from the firmware's boot manager. 2. Refine logic about validate boot option and coding style. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2010.SR1@13395 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c6
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c54
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c1
3 files changed, 19 insertions, 42 deletions
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
index c9c694e648..1c0c6dc646 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
@@ -812,6 +812,12 @@ BdsLibBootViaBootOption (
ImageInfo->LoadOptionsSize = Option->LoadOptionsSize;
ImageInfo->LoadOptions = Option->LoadOptions;
}
+
+ //
+ // Clean to NULL because the image is loaded directly from the firmwares boot manager.
+ //
+ ImageInfo->ParentHandle = NULL;
+
//
// Before calling the image, enable the Watchdog Timer for
// the 5 Minute period
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
index ada77d26de..5841756c43 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
@@ -455,7 +455,7 @@ GetDevicePathSizeEx (
bigger than MaxStringLen, return length 0 to indicate that this is an
invalidate string.
- This function returns the number of Unicode characters in the Null-terminated
+ This function returns the byte length of Unicode characters in the Null-terminated
Unicode string specified by String.
If String is NULL, then ASSERT().
@@ -479,13 +479,13 @@ StrSizeEx (
ASSERT (String != NULL && MaxStringLen != 0);
ASSERT (((UINTN) String & BIT0) == 0);
- for (Length = 0; *String != L'\0' && MaxStringLen != Length; String++, Length++);
+ for (Length = 0; *String != L'\0' && MaxStringLen != Length; String++, Length+=2);
if (*String != L'\0' && MaxStringLen == Length) {
return 0;
}
- return (Length + 1) * sizeof (*String);
+ return Length + 2;
}
/**
@@ -507,9 +507,12 @@ ValidateOption (
UINT16 FilePathSize;
UINT8 *TempPtr;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_DEVICE_PATH_PROTOCOL *TempPath;
UINTN TempSize;
+ if (VariableSize <= sizeof (UINT16) + sizeof (UINT32)) {
+ return FALSE;
+ }
+
//
// Skip the option attribute
//
@@ -525,14 +528,14 @@ ValidateOption (
//
// Get the option's description string size
//
- TempSize = StrSizeEx ((CHAR16 *) TempPtr, VariableSize);
+ TempSize = StrSizeEx ((CHAR16 *) TempPtr, VariableSize - sizeof (UINT16) - sizeof (UINT32));
TempPtr += TempSize;
//
// Get the option's device path
//
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;
- TempPtr += FilePathSize;
+ TempPtr += FilePathSize;
//
// Validation boot option variable.
@@ -541,21 +544,11 @@ ValidateOption (
return FALSE;
}
- if (TempSize + FilePathSize + sizeof (UINT16) + sizeof (UINT16) > VariableSize) {
+ if (TempSize + FilePathSize + sizeof (UINT16) + sizeof (UINT32) > VariableSize) {
return FALSE;
}
- TempPath = DevicePath;
- while (FilePathSize > 0) {
- TempSize = GetDevicePathSizeEx (TempPath, FilePathSize);
- if (TempSize == 0) {
- return FALSE;
- }
- FilePathSize = (UINT16) (FilePathSize - TempSize);
- TempPath += TempSize;
- }
-
- return TRUE;
+ return (BOOLEAN) (GetDevicePathSizeEx (DevicePath, FilePathSize) != 0);
}
/**
@@ -608,13 +601,12 @@ BdsLibVariableToOption (
UINT8 *TempPtr;
UINTN VariableSize;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_DEVICE_PATH_PROTOCOL *TempPath;
BDS_COMMON_OPTION *Option;
VOID *LoadOptions;
UINT32 LoadOptionsSize;
CHAR16 *Description;
UINT8 NumOff;
- UINTN TempSize;
+
//
// Read the variable. We will never free this data.
//
@@ -659,11 +651,7 @@ BdsLibVariableToOption (
//
// Get the option's description string size
//
- TempSize = StrSizeEx ((CHAR16 *) TempPtr, VariableSize);
- if (TempSize == 0) {
- return NULL;
- }
- TempPtr += TempSize;
+ TempPtr += StrSize((CHAR16 *) TempPtr);
//
// Get the option's device path
@@ -672,25 +660,9 @@ BdsLibVariableToOption (
TempPtr += FilePathSize;
//
- // Validation device path.
- //
- TempPath = DevicePath;
- while (FilePathSize > 0) {
- TempSize = GetDevicePathSizeEx (TempPath, FilePathSize);
- if (TempSize == 0) {
- return NULL;
- }
- FilePathSize = (UINT16) (FilePathSize - TempSize);
- TempPath += TempSize;
- }
-
- //
// Get load opion data.
//
LoadOptions = TempPtr;
- if (VariableSize < (UINTN)(TempPtr - Variable)) {
- return NULL;
- }
LoadOptionsSize = (UINT32) (VariableSize - (UINTN) (TempPtr - Variable));
//
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
index e0862aed5e..ecccc0648e 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -333,7 +333,6 @@ IsValidDevicePath (
@param VariableName Input console variable name.
**/
-
VOID
BdsFormalizeConsoleVariable (
IN CHAR16 *VariableName