Return a copy of config value, so that it won't get altered
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 29s
Builds / ExectOS (i686) (push) Successful in 28s

This commit is contained in:
Rafal Kupiec 2024-01-09 16:24:57 +01:00
parent a674d2eb1b
commit cb4bd3db8b
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4

View File

@ -25,10 +25,12 @@ BlGetConfigValue(IN CONST PWCHAR ConfigName)
{
PXTBL_CONFIG_ENTRY ConfigEntry;
PLIST_ENTRY ConfigListEntry;
SIZE_T Length;
SIZE_T KeyLength, ValueLength;
EFI_STATUS Status;
PWCHAR Value;
/* Get config entry name length */
Length = RtlWideStringLength(ConfigName, 0);
KeyLength = RtlWideStringLength(ConfigName, 0);
/* Iterate through config entries */
ConfigListEntry = BlpConfig.Flink;
@ -38,10 +40,24 @@ BlGetConfigValue(IN CONST PWCHAR ConfigName)
ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink);
/* Check if requested configuration found */
if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, Length) == 0)
if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, KeyLength) == 0)
{
/* Return config value */
return ConfigEntry->Value;
/* Get value length */
ValueLength = RtlWideStringLength(ConfigEntry->Value, 0);
/* Allocate memory for value */
Status = BlMemoryAllocatePool(ValueLength * sizeof(WCHAR), (PVOID *)&Value);
if(Status != STATUS_EFI_SUCCESS)
{
/* Memory allocation failure, return NULL */
BlDebugPrint(L"ERROR: Memory allocation failure (Status Code: 0x%lx)\n", Status);
return NULL;
}
/* Copy value and return it */
RtlCopyMemory(Value, ConfigEntry->Value, ValueLength * sizeof(WCHAR));
Value[ValueLength] = 0;
return Value;
}
/* Move to the next config entry */