bigger than MaxStringLen, return length 0 to indicate that this is an \r
invalidate string.\r
\r
- This function returns the number of Unicode characters in the Null-terminated\r
+ This function returns the byte length of Unicode characters in the Null-terminated\r
Unicode string specified by String. \r
\r
If String is NULL, then ASSERT().\r
ASSERT (String != NULL && MaxStringLen != 0);\r
ASSERT (((UINTN) String & BIT0) == 0);\r
\r
- for (Length = 0; *String != L'\0' && MaxStringLen != Length; String++, Length++);\r
+ for (Length = 0; *String != L'\0' && MaxStringLen != Length; String++, Length+=2);\r
\r
if (*String != L'\0' && MaxStringLen == Length) {\r
return 0;\r
}\r
\r
- return (Length + 1) * sizeof (*String);\r
+ return Length + 2;\r
}\r
\r
/**\r
UINT16 FilePathSize;\r
UINT8 *TempPtr;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *TempPath;\r
UINTN TempSize;\r
\r
+ if (VariableSize <= sizeof (UINT16) + sizeof (UINT32)) {\r
+ return FALSE;\r
+ }\r
+\r
//\r
// Skip the option attribute\r
//\r
//\r
// Get the option's description string size\r
//\r
- TempSize = StrSizeEx ((CHAR16 *) TempPtr, VariableSize);\r
+ TempSize = StrSizeEx ((CHAR16 *) TempPtr, VariableSize - sizeof (UINT16) - sizeof (UINT32));\r
TempPtr += TempSize;\r
\r
//\r
// Get the option's device path\r
//\r
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
- TempPtr += FilePathSize;\r
+ TempPtr += FilePathSize;\r
\r
//\r
// Validation boot option variable.\r
return FALSE;\r
}\r
\r
- if (TempSize + FilePathSize + sizeof (UINT16) + sizeof (UINT16) > VariableSize) {\r
+ if (TempSize + FilePathSize + sizeof (UINT16) + sizeof (UINT32) > VariableSize) {\r
return FALSE;\r
}\r
\r
- TempPath = DevicePath;\r
- while (FilePathSize > 0) {\r
- TempSize = GetDevicePathSizeEx (TempPath, FilePathSize);\r
- if (TempSize == 0) {\r
- return FALSE;\r
- }\r
- FilePathSize = (UINT16) (FilePathSize - TempSize);\r
- TempPath += TempSize;\r
- }\r
-\r
- return TRUE;\r
+ return GetDevicePathSizeEx (DevicePath, FilePathSize) != 0;\r
}\r
\r
/**\r
UINT8 *TempPtr;\r
UINTN VariableSize;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *TempPath;\r
BDS_COMMON_OPTION *Option;\r
VOID *LoadOptions;\r
UINT32 LoadOptionsSize;\r
CHAR16 *Description;\r
UINT8 NumOff;\r
- UINTN TempSize;\r
+\r
//\r
// Read the variable. We will never free this data.\r
//\r
//\r
// Get the option's description string size\r
//\r
- TempSize = StrSizeEx ((CHAR16 *) TempPtr, VariableSize);\r
- if (TempSize == 0) {\r
- return NULL;\r
- }\r
- TempPtr += TempSize;\r
+ TempPtr += StrSize((CHAR16 *) TempPtr);\r
\r
//\r
// Get the option's device path\r
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
TempPtr += FilePathSize;\r
\r
- //\r
- // Validation device path.\r
- //\r
- TempPath = DevicePath;\r
- while (FilePathSize > 0) {\r
- TempSize = GetDevicePathSizeEx (TempPath, FilePathSize);\r
- if (TempSize == 0) {\r
- return NULL;\r
- }\r
- FilePathSize = (UINT16) (FilePathSize - TempSize);\r
- TempPath += TempSize;\r
- }\r
-\r
//\r
// Get load opion data.\r
//\r
LoadOptions = TempPtr;\r
- if (VariableSize < (UINTN)(TempPtr - Variable)) {\r
- return NULL;\r
- }\r
LoadOptionsSize = (UINT32) (VariableSize - (UINTN) (TempPtr - Variable));\r
\r
//\r