mirror of
https://github.com/aramperes/nut-rs.git
synced 2025-09-08 05:08:31 -04:00
fix: Prevent panic caused by subtracting with overflow (#36)
This bug occurred if the string was empty (e.g. from a lost connection)
This commit is contained in:
parent
8ef85f3b28
commit
8712a6087b
2 changed files with 2 additions and 2 deletions
|
@ -138,7 +138,7 @@ impl TcpConnection {
|
|||
if debug {
|
||||
eprint!("DEBUG <- {}", raw);
|
||||
}
|
||||
raw = raw[..raw.len() - 1].to_string(); // Strip off \n
|
||||
raw = raw.trim_end_matches('\n').to_string(); // Strip off \n
|
||||
|
||||
// Parse args by splitting whitespace, minding quotes for args with multiple words
|
||||
let args = shell_words::split(&raw)
|
||||
|
|
|
@ -144,7 +144,7 @@ impl TcpConnection {
|
|||
if debug {
|
||||
eprint!("DEBUG <- {}", raw);
|
||||
}
|
||||
raw = raw[..raw.len() - 1].to_string(); // Strip off \n
|
||||
raw = raw.trim_end_matches('\n').to_string(); // Strip off \n
|
||||
|
||||
// Parse args by splitting whitespace, minding quotes for args with multiple words
|
||||
let args = shell_words::split(&raw)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue