fix(smart): handle negative ATA device statistics values (#1791)

This commit is contained in:
henrygd
2026-03-08 13:34:16 -04:00
parent 73c262455d
commit 638e7dc12a
3 changed files with 41 additions and 4 deletions

View File

@@ -223,7 +223,7 @@ func (sm *SmartManager) ScanDevices(force bool) error {
}
func (sm *SmartManager) parseConfiguredDevices(config string) ([]*DeviceInfo, error) {
splitChar := os.Getenv("SMART_DEVICES_SEPARATOR")
splitChar, _ := utils.GetEnv("SMART_DEVICES_SEPARATOR")
if splitChar == "" {
splitChar = ","
}
@@ -919,7 +919,7 @@ func temperatureFromAtaDeviceStatistics(stats smart.AtaDeviceStatistics) (uint8,
if entry == nil || entry.Value == nil {
return 0, false
}
if *entry.Value > 255 {
if *entry.Value < 0 || *entry.Value > 255 {
return 0, false
}
return uint8(*entry.Value), true