From 7e426f24ddcf858b7245071e08e09e5e5c55182a Mon Sep 17 00:00:00 2001 From: Markus Ressel Date: Sun, 19 Dec 2021 15:51:05 +0100 Subject: [PATCH] added validation check for hwmon index --- internal/configuration/config.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/configuration/config.go b/internal/configuration/config.go index 8885035..bd583fc 100644 --- a/internal/configuration/config.go +++ b/internal/configuration/config.go @@ -114,6 +114,12 @@ func validateSensors(config *Configuration) { if !isSensorConfigInUse(sensorConfig, config.Curves) { ui.Warning("Unused sensor configuration: %s", sensorConfig.ID) } + + if sensorConfig.HwMon != nil { + if sensorConfig.HwMon.Index <= 0 { + ui.Fatal("Sensor %s: invalid index, must be >= 1", sensorConfig.ID) + } + } } } @@ -209,5 +215,11 @@ func validateFans(config *Configuration) { if len(fanConfig.Curve) <= 0 { ui.Fatal("Fan %s: missing curve definition in configuration entry", fanConfig.ID) } + + if fanConfig.HwMon != nil { + if fanConfig.HwMon.Index <= 0 { + ui.Fatal("Fan %s: invalid index, must be >= 1", fanConfig.ID) + } + } } }