From 96407018fb8a43a0f7a0a8a621e57b91f71cf4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Domeradzki?= Date: Sat, 4 Jan 2025 14:47:53 +0100 Subject: [PATCH] Don't allow to run with invalid IPCPassword This scenario would throw when IPC is required to compare provided password with hash in the config. Instead, yell at user and prevent them from running with such config at all. --- ArchiSteamFarm/Storage/GlobalConfig.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ArchiSteamFarm/Storage/GlobalConfig.cs b/ArchiSteamFarm/Storage/GlobalConfig.cs index 5c64ca98c..49a283e17 100644 --- a/ArchiSteamFarm/Storage/GlobalConfig.cs +++ b/ArchiSteamFarm/Storage/GlobalConfig.cs @@ -504,6 +504,21 @@ public sealed class GlobalConfig { return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(IPCPasswordFormat), IPCPasswordFormat)); } + switch (IPCPasswordFormat) { + case ArchiCryptoHelper.EHashingMethod.Pbkdf2 when !string.IsNullOrEmpty(IPCPassword): + case ArchiCryptoHelper.EHashingMethod.SCrypt when !string.IsNullOrEmpty(IPCPassword): + try { + // Ensure IPCPassword is in the appropriate format, base64-encoded string in this case + _ = Convert.FromBase64String(IPCPassword); + } catch (FormatException e) { + ASF.ArchiLogger.LogGenericWarningException(e); + + return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(IPCPassword), IPCPassword)); + } + + break; + } + if (MaxFarmingTime == 0) { return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(MaxFarmingTime), MaxFarmingTime)); }