X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=EdkModulePkg%2FUniversal%2FVariable%2FRuntimeDxe%2FVariable.c;h=5d631a53682b91515f3bffb59265e2957f4e4cab;hb=3088e811376d8893366c0a48d493b480e3e96fda;hp=3fa16172cc765db9e96d1dce794fc6bc9def088c;hpb=202c5d55e5a5a1f065038cda8316ad36293aa6bb;p=mirror_edk2.git diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 3fa16172cc..5d631a5368 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -815,7 +815,8 @@ Returns: // 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. // - else if (sizeof (VARIABLE_HEADER) + ArrayLength (VariableName) + DataSize > MAX_VARIABLE_SIZE) { + else if ((DataSize > MAX_VARIABLE_SIZE) || + (sizeof (VARIABLE_HEADER) + ArrayLength (VariableName) + DataSize > MAX_VARIABLE_SIZE)) { return EFI_INVALID_PARAMETER; } // @@ -1310,8 +1311,6 @@ Returns: (((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength); VariableStoreEntry.Length = (UINT64) PcdGet32 (PcdFlashNvStorageVariableSize) - \ (((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength); - - VariableStoreEntry.Length = (UINT64) PcdGet32 (PcdFlashNvStorageVariableSize); // // Mark the variable storage region of the FLASH as RUNTIME // @@ -1390,6 +1389,23 @@ Returns: mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) NextVariable - (UINTN) CurrPtr; + // + // Check if the free area is blow a threshold + // + if ((((VARIABLE_STORE_HEADER *)((UINTN) CurrPtr))->Size - mVariableModuleGlobal->NonVolatileLastVariableOffset) < VARIABLE_RECLAIM_THRESHOLD) { + Status = Reclaim ( + mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase, + &mVariableModuleGlobal->NonVolatileLastVariableOffset, + FALSE + ); + } + + if (EFI_ERROR (Status)) { + gBS->FreePool (mVariableModuleGlobal); + gBS->FreePool (VolatileVariableStore); + return Status; + } + // // Check if the free area is really free. //