From dae5653e0ff39c95e402ebcac2103fb0f35d5477 Mon Sep 17 00:00:00 2001 From: Clemens Vasters Date: Fri, 30 Aug 2024 10:14:47 +0200 Subject: [PATCH] fix for #76 - not checking whether HOME env variable is defined before using it --- src/Microsoft.Azure.Relay.Bridge/Configuration/Config.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Azure.Relay.Bridge/Configuration/Config.cs b/src/Microsoft.Azure.Relay.Bridge/Configuration/Config.cs index 47ed0d2..5284aa5 100644 --- a/src/Microsoft.Azure.Relay.Bridge/Configuration/Config.cs +++ b/src/Microsoft.Azure.Relay.Bridge/Configuration/Config.cs @@ -480,9 +480,10 @@ public static Config LoadConfig(CommandLineSettings commandLineSettings) if (string.IsNullOrEmpty(commandLineSettings.ConfigFile)) { + string homeDir = Environment.GetEnvironmentVariable("HOME"); string userConfigFileName = - (Environment.OSVersion.Platform == PlatformID.Unix) ? - Path.Combine(Environment.GetEnvironmentVariable("HOME"), $".{azbridge}/{azbridge}_config.yml") : + (Environment.OSVersion.Platform == PlatformID.Unix && !string.IsNullOrEmpty(homeDir)) ? + Path.Combine(homeDir, $".{azbridge}/{azbridge}_config.yml") : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), $"{azbridge}\\{azbridge}_config.yml"); Config userConfig = LoadConfigFile(userConfigFileName);