X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=EdkModulePkg%2FUniversal%2FUserInterface%2FHiiDataBase%2FDxe%2FForms.c;h=b7b02a85f8919a7d606372fdfdf69dc2d9cf8367;hb=137749b7ed48dad505eafaf187f24aa8cfd09300;hp=a0a9619197795a20ac30e1a990df64e84cb4b7c1;hpb=878ddf1fc3540a715f63594ed22b6929e881afb4;p=mirror_edk2.git diff --git a/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Forms.c b/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Forms.c index a0a9619197..b7b02a85f8 100644 --- a/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Forms.c +++ b/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Forms.c @@ -1,6 +1,7 @@ -/*++ - -Copyright (c) 2006, Intel Corporation +/**@file + This file contains the form processing code to the HII database. + +Copyright (c) 2006 - 2007 Intel Corporation.
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 @@ -9,19 +10,12 @@ 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. -Module Name: - - Forms.c - -Abstract: - - This file contains the form processing code to the HII database. - ---*/ +**/ #include "HiiDatabase.h" +STATIC CHAR16* Ascii2Unicode ( OUT CHAR16 *UnicodeStr, @@ -54,6 +48,7 @@ Ascii2Unicode ( } } +STATIC CHAR8* Unicode2Ascii ( OUT CHAR8 *AsciiStr, @@ -86,6 +81,7 @@ Unicode2Ascii ( } } +STATIC VOID ExtractDevicePathData ( IN EFI_HII_DATA_TABLE *DataTable, @@ -129,6 +125,7 @@ Returns: *ExportBufferPtr = ExportBuffer; } +STATIC VOID ExtractVariableData ( IN OUT EFI_HII_DATA_TABLE *DataTable, @@ -144,11 +141,11 @@ Routine Description: Arguments: - DataTable ¨C On input, this parameter point to the EFI_HII_DATA_TABLE structure + DataTable - On input, this parameter point to the EFI_HII_DATA_TABLE structure of the final data buffer for the EFI_HII_EXPORT interface. This function update the NumberOfVariableData attribute. IfrData - It points to a staring address of a EFI_HII_IFR_PACK structure. - ExportBufferPtr ¨C On input, it points the starting address of the data buffer to + ExportBufferPtr - On input, it points the starting address of the data buffer to host the variable pack. On output, it is the starting address of data buffer for the next extraction operation. Returns: @@ -205,6 +202,7 @@ Returns: &gEfiFormCallbackProtocolGuid, (VOID *) &FormCallback ); + ASSERT_EFI_ERROR (Status); } // // Since we have a "Setup" variable that wasn't specified by a variable op-code @@ -240,6 +238,7 @@ Returns: &TempValue, ExportBuffer ); + ASSERT_EFI_ERROR (Status); } else { Status = gRT->GetVariable ( (CHAR16 *) SETUP_MAP_NAME, @@ -248,6 +247,7 @@ Returns: &TempValue, ExportBuffer ); + ASSERT_EFI_ERROR (Status); } ExportBuffer = (UINT8 *) (UINTN) (((UINTN) ExportBuffer) + TempValue); @@ -306,6 +306,7 @@ Returns: &TempValue, ExportBuffer ); + ASSERT_EFI_ERROR (Status); } else { Status = gRT->GetVariable ( String, @@ -314,6 +315,7 @@ Returns: &TempValue, ExportBuffer ); + ASSERT_EFI_ERROR (Status); } ExportBuffer = (UINT8 *) (UINTN) (((UINTN) ExportBuffer) + TempValue); @@ -367,7 +369,6 @@ Returns: UINT8 *ExportBuffer; EFI_HII_EXPORT_TABLE *ExportTable; EFI_HII_DATA_TABLE *DataTable; - BOOLEAN InsufficientSize; BOOLEAN VariableExist; UINT16 NumberOfHiiDataTables; UINTN SizeNeeded; @@ -386,7 +387,6 @@ Returns: FormPack = NULL; RawData = NULL; PackageInstance = NULL; - InsufficientSize = FALSE; NumberOfHiiDataTables = 0; VariableSize = 0; TempValue = 0; @@ -731,6 +731,7 @@ Returns: EFI_IFR_FORM *Form; EFI_IFR_OP_HEADER *Location; UINT16 *BufferLength = (UINT16 *) BufferLengthTemp; + UINTN FormLength; if (This == NULL) { return EFI_INVALID_PARAMETER; @@ -742,6 +743,8 @@ Returns: PackageInstance = NULL; + FormLength = 0; + // // Check numeric value against the head of the database // @@ -802,19 +805,27 @@ Returns: // If we found a Form Op-code and it is of the correct Id, copy it and return // if (Form->FormId == FormId) { - if (Location->Length > *BufferLength || Buffer == NULL) { - *BufferLength = Location->Length; - return EFI_BUFFER_TOO_SMALL; - } else { - for (; Location->OpCode != EFI_IFR_END_FORM_OP;) { - CopyMem (Buffer, Location, Location->Length); - Buffer = Buffer + Location->Length; - Location = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (Location) + Location->Length); - } + // + // Calculate the total size of form + // + for (FormLength = 0; Location->OpCode != EFI_IFR_END_FORM_OP; ) { + FormLength += Location->Length; + Location = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (Location) + Location->Length); + } + FormLength += Location->Length; + Location = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (Location) + Location->Length); - CopyMem (Buffer, Location, Location->Length); - return EFI_SUCCESS; + if ((Buffer == NULL) || (FormLength > *BufferLength)) { + *BufferLengthTemp = FormLength; + return EFI_BUFFER_TOO_SMALL; } + + // + // Rewind to start offset of the found Form + // + Location = (EFI_IFR_OP_HEADER *) ((CHAR8 *)Location - FormLength); + CopyMem (Buffer, Location, FormLength); + return EFI_SUCCESS; } default: @@ -827,7 +838,7 @@ Returns: } } - return EFI_SUCCESS; + return EFI_NOT_FOUND; } // @@ -1409,6 +1420,8 @@ Returns: TempBufferSize += PackageInstance->IfrSize + PackageInstance->StringSize; TempBuffer = AllocateZeroPool (TempBufferSize); + ASSERT (TempBuffer != NULL); + OrigTempBuffer = TempBuffer; //