Fix filesystem metric parsing bounds error in dashboard
All checks were successful
Build and Release / build-and-release (push) Successful in 1m8s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m8s
Prevent string slicing panic in extract_filesystem_metric when parsing individual filesystem metrics. This resolves the issue where filesystem entries show —% —GB/—GB instead of actual usage.
This commit is contained in:
@@ -391,8 +391,12 @@ impl SystemWidget {
|
||||
|
||||
for suffix in known_suffixes {
|
||||
if after_fs.ends_with(suffix) {
|
||||
let fs_name = after_fs[..after_fs.len() - suffix.len() - 1].to_string(); // Remove suffix + underscore
|
||||
return (Some(fs_name), Some(suffix.to_string()));
|
||||
// Safely calculate fs_name length
|
||||
let suffix_with_underscore = suffix.len() + 1;
|
||||
if after_fs.len() > suffix_with_underscore {
|
||||
let fs_name = after_fs[..after_fs.len() - suffix_with_underscore].to_string();
|
||||
return (Some(fs_name), Some(suffix.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user