From 759ba2a10ac4db2895ebec3a97f3aa42ff7558b8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 15 May 2025 21:07:05 +0300 Subject: [PATCH] battery: tighten treshhold validation --- src/battery.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/battery.rs b/src/battery.rs index 15823a9..5fb41d4 100644 --- a/src/battery.rs +++ b/src/battery.rs @@ -92,6 +92,11 @@ pub fn set_battery_charge_thresholds(start_threshold: u8, stop_threshold: u8) -> /// Validates that the threshold values are in acceptable ranges fn validate_thresholds(start_threshold: u8, stop_threshold: u8) -> Result<()> { + if start_threshold == 0 || stop_threshold == 0 { + return Err(ControlError::InvalidValueError( + "Thresholds must be greater than 0%".to_string(), + )); + } if start_threshold >= stop_threshold { return Err(ControlError::InvalidValueError(format!( "Start threshold ({start_threshold}) must be less than stop threshold ({stop_threshold})"