/** @file\r
HII Library implementation that uses DXE protocols and services.\r
\r
- Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2017, 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
for freeing the allocated buffer using FreePool().\r
\r
@param Handle The HII handle.\r
- @param Buffer On return, opints to a pointer which point to the buffer that contain the formset opcode.\r
+ @param Buffer On return, points to a pointer which point to the buffer that contain the formset opcode.\r
@param BufferSize On return, points to the length of the buffer.\r
\r
@retval EFI_OUT_OF_RESOURCES No enough memory resource is allocated.\r
@retval EFI_NOT_FOUND Can't find the package data for the input Handle.\r
@retval EFI_INVALID_PARAMETER The input parameters are not correct.\r
- @retval EFI_SUCCESS Get the formset opcode from the hii handle sucessfully.\r
+ @retval EFI_SUCCESS Get the formset opcode from the hii handle successfully.\r
\r
**/\r
EFI_STATUS\r
\r
if (FormSetBuffer != NULL){\r
TempBuffer = AllocateCopyPool (TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length, FormSetBuffer);\r
- CopyMem (TempBuffer + TempSize, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length);\r
FreePool(FormSetBuffer);\r
+ FormSetBuffer = NULL;\r
+ if (TempBuffer == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ CopyMem (TempBuffer + TempSize, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length);\r
} else {\r
TempBuffer = AllocateCopyPool (TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length, OpCodeData);\r
+ if (TempBuffer == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
}\r
TempSize += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;\r
FormSetBuffer = TempBuffer;\r
break;\r
}\r
}\r
+Done:\r
FreePool (HiiPackageList);\r
\r
*BufferSize = TempSize;\r
\r
@param[in] Guid Pointer to an EFI_GUID that is the routing information\r
GUID. Each of the 16 bytes in Guid is converted to \r
- a 2 Unicode character hexidecimal string. This is \r
+ a 2 Unicode character hexadecimal string. This is\r
an optional parameter that may be NULL.\r
@param[in] Name Pointer to a Null-terminated Unicode string that is \r
the routing information NAME. This is an optional \r
parameter that may be NULL. Each 16-bit Unicode \r
character in Name is converted to a 4 character Unicode \r
- hexidecimal string. \r
+ hexadecimal string.\r
@param[in] DriverHandle The driver handle which supports a Device Path Protocol\r
that is the routing information PATH. Each byte of\r
the Device Path associated with DriverHandle is converted\r
- to a 2 Unicode character hexidecimal string.\r
+ to a 2 Unicode character hexadecimal string.\r
\r
@retval NULL DriverHandle does not support the Device Path Protocol.\r
@retval Other A pointer to the Null-terminate Unicode <ConfigHdr> string\r
// Append Guid converted to <HexCh>32\r
//\r
for (Index = 0, Buffer = (UINT8 *)Guid; Index < sizeof (EFI_GUID); Index++) {\r
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2);\r
+ UnicodeValueToStringS (\r
+ String,\r
+ MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString),\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ *(Buffer++),\r
+ 2\r
+ );\r
+ String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16));\r
}\r
}\r
\r
// Append Name converted to <Char>NameLength\r
//\r
for (; *Name != L'\0'; Name++) {\r
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *Name, 4);\r
+ UnicodeValueToStringS (\r
+ String,\r
+ sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString),\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ *Name,\r
+ 4\r
+ );\r
+ String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16));\r
}\r
}\r
\r
// Append the device path associated with DriverHandle converted to <HexChar>DevicePathSize\r
//\r
for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) {\r
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2);\r
+ UnicodeValueToStringS (\r
+ String,\r
+ sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString),\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ *(Buffer++),\r
+ 2\r
+ );\r
+ String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16));\r
}\r
\r
//\r
UINT64 VarValue;\r
EFI_IFR_TYPE_VALUE TmpValue;\r
EFI_STATUS Status;\r
- EFI_HII_PACKAGE_HEADER PacakgeHeader;\r
+ EFI_HII_PACKAGE_HEADER PackageHeader;\r
UINT32 PackageOffset;\r
UINT8 *PackageData;\r
UINTN IfrOffset;\r
//\r
PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
while (PackageOffset < PackageListLength) {\r
- CopyMem (&PacakgeHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PacakgeHeader));\r
+ CopyMem (&PackageHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PackageHeader));\r
\r
//\r
// Parse IFR opcode from the form package.\r
//\r
- if (PacakgeHeader.Type == EFI_HII_PACKAGE_FORMS) {\r
- IfrOffset = sizeof (PacakgeHeader);\r
+ if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {\r
+ IfrOffset = sizeof (PackageHeader);\r
PackageData = (UINT8 *) HiiPackageList + PackageOffset;\r
- while (IfrOffset < PacakgeHeader.Length) {\r
+ while (IfrOffset < PackageHeader.Length) {\r
IfrOpHdr = (EFI_IFR_OP_HEADER *) (PackageData + IfrOffset);\r
//\r
// Validate current setting to the value built in IFR opcode\r
//\r
// Go to next package.\r
//\r
- PackageOffset += PacakgeHeader.Length;\r
+ PackageOffset += PackageHeader.Length;\r
}\r
\r
return EFI_SUCCESS;\r
//\r
// Check whether VarBuffer is enough\r
//\r
- if ((UINTN) (Offset + Width) > MaxBufferSize) {\r
+ if ((UINT32)Offset + Width > MaxBufferSize) {\r
DataBuffer = ReallocatePool (\r
MaxBufferSize,\r
Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE,\r
@param DefaultId Specifies the type of defaults to retrieve only for setting default action.\r
@param ActionType Action supports setting defaults and validate current setting.\r
\r
- @retval TURE Action runs successfully.\r
+ @retval TRUE Action runs successfully.\r
@retval FALSE Action is not valid or Action can't be executed successfully..\r
**/\r
BOOLEAN\r
entirety of the current HII database will be reset.\r
@param DefaultId Specifies the type of defaults to retrieve.\r
\r
- @retval TURE The default value is set successfully.\r
+ @retval TRUE The default value is set successfully.\r
@retval FALSE The default value can't be found and set.\r
**/\r
BOOLEAN\r
UINTN BufferSize;\r
UINT8 *UpdateBufferPos;\r
EFI_HII_PACKAGE_HEADER *Package;\r
- EFI_HII_PACKAGE_HEADER *TempPacakge;\r
+ EFI_HII_PACKAGE_HEADER *TempPackage;\r
EFI_HII_PACKAGE_HEADER PackageHeader;\r
BOOLEAN Updated;\r
HII_LIB_OPCODE_BUFFER *OpCodeBufferStart;\r
ASSERT (HiiHandle != NULL);\r
ASSERT (StartOpCodeHandle != NULL);\r
UpdatePackageList = NULL;\r
- TempPacakge = NULL;\r
+ TempPackage = NULL;\r
HiiPackageList = NULL;\r
\r
//\r
//\r
// Allocate temp buffer to store the temp updated package buffer\r
//\r
- TempPacakge = AllocateZeroPool (BufferSize);\r
- if (TempPacakge == NULL) {\r
+ TempPackage = AllocateZeroPool (BufferSize);\r
+ if (TempPackage == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Finish;\r
}\r
//\r
// Check this package is the matched package.\r
//\r
- Status = InternalHiiUpdateFormPackageData (FormSetGuid, FormId, Package, OpCodeBufferStart, OpCodeBufferEnd, TempPacakge);\r
+ Status = InternalHiiUpdateFormPackageData (FormSetGuid, FormId, Package, OpCodeBufferStart, OpCodeBufferEnd, TempPackage);\r
//\r
// The matched package is found. Its package buffer will be updated by the input new data.\r
//\r
//\r
// Add updated package buffer\r
//\r
- Package = TempPacakge;\r
+ Package = TempPackage;\r
}\r
}\r
\r
FreePool (UpdatePackageList);\r
}\r
\r
- if (TempPacakge != NULL) {\r
- FreePool (TempPacakge);\r
+ if (TempPackage != NULL) {\r
+ FreePool (TempPackage);\r
}\r
\r
return Status; \r