From 782e6e3987be6d579ba7d28dadd9f358fd47d773 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Thu, 21 Dec 2023 20:02:02 +0100 Subject: [PATCH] Make sure config list is not empty before trying to access it --- xtldr2/config.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/xtldr2/config.c b/xtldr2/config.c index 28d9927..7a34cf1 100644 --- a/xtldr2/config.c +++ b/xtldr2/config.c @@ -30,22 +30,26 @@ BlGetConfigValue(IN CONST PWCHAR ConfigName) /* Get config entry name length */ Length = RtlWideStringLength(ConfigName, 0); - /* Iterate through config entries */ - ConfigListEntry = BlpConfig->Flink; - while(ConfigListEntry != BlpConfig) + /* Make sure config list is not empty */ + if(BlpConfig != NULL) { - /* Get config entry */ - ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink); - - /* Check if requested configuration found */ - if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, Length) == 0) + /* Iterate through config entries */ + ConfigListEntry = BlpConfig->Flink; + while(ConfigListEntry != BlpConfig) { - /* Return config value */ - return ConfigEntry->Value; - } + /* Get config entry */ + ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink); - /* Move to the next config entry */ - ConfigListEntry = ConfigListEntry->Flink; + /* Check if requested configuration found */ + if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, Length) == 0) + { + /* Return config value */ + return ConfigEntry->Value; + } + + /* Move to the next config entry */ + ConfigListEntry = ConfigListEntry->Flink; + } } /* Config entry not found, return NULL */