aramperes / nut-rs

rups: A Network UPS Tools (NUT) implementation in Rust.
https://crates.io/crates/rups
MIT License
24 stars 3 forks source link

fix: Prevent panic caused by subtracting with overflow #36

Closed hubertpawlak closed 1 year ago

hubertpawlak commented 1 year ago

This pull request fixes a bug that caused panic when trying to subtract the last character from an empty string. This could happen if there was a lost connection and the returned string was empty. I experienced this when running rups for a longer period of time on Wi-Fi.

I verified the fix by simulating packet loss with nftables on Linux.

aramperes commented 1 year ago

Sorry for the delay, I missed this email