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.
This commit is contained in:
Łukasz Domeradzki
2025-01-04 14:47:53 +01:00
parent 1f78dbb553
commit 96407018fb

View File

@@ -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));
}