diff --git a/src/parsers/fixtures/SIGABRT.PID.84191.TIME.2019-08-21.20.04.09.fuzz b/src/parsers/fixtures/SIGABRT.PID.84191.TIME.2019-08-21.20.04.09.fuzz new file mode 100644 index 0000000..6ba466b Binary files /dev/null and b/src/parsers/fixtures/SIGABRT.PID.84191.TIME.2019-08-21.20.04.09.fuzz differ diff --git a/src/parsers/mod.rs b/src/parsers/mod.rs index ba9907f..8570ce6 100644 --- a/src/parsers/mod.rs +++ b/src/parsers/mod.rs @@ -448,4 +448,13 @@ errors: No known data errors assert_eq!(&topo, &zpool); } + + #[test] + fn test_zpool_int_overflow() { + let stdout = include_str!("fixtures/SIGABRT.PID.84191.TIME.2019-08-21.20.04.09.fuzz"); + let mut pairs = + StdoutParser::parse(Rule::zpools, stdout).unwrap_or_else(|e| panic!("{}", e)); + let pair = pairs.next().unwrap(); + let zpool = Zpool::from_pest_pair(pair); + } } diff --git a/src/zpool/description.rs b/src/zpool/description.rs index ca087d6..e8da197 100644 --- a/src/zpool/description.rs +++ b/src/zpool/description.rs @@ -124,9 +124,9 @@ fn get_error_statistics_from_pair(pair: Pair<'_, Rule>) -> ErrorStatistics { debug_assert_eq!(Rule::error_statistics, pair.as_rule()); let mut inner = pair.into_inner(); ErrorStatistics { - read: inner.next().unwrap().as_span().as_str().parse().unwrap(), - write: inner.next().unwrap().as_span().as_str().parse().unwrap(), - checksum: inner.next().unwrap().as_span().as_str().parse().unwrap(), + read: inner.next().unwrap().as_span().as_str().parse().unwrap_or(std::u64::MAX), + write: inner.next().unwrap().as_span().as_str().parse().unwrap_or(std::u64::MAX), + checksum: inner.next().unwrap().as_span().as_str().parse().unwrap_or(std::u64::MAX), } } diff --git a/src/zpool/vdev.rs b/src/zpool/vdev.rs index 531d4f2..5e8df3b 100644 --- a/src/zpool/vdev.rs +++ b/src/zpool/vdev.rs @@ -32,13 +32,15 @@ use std::{default::Default, use crate::zpool::{Health, Reason, ZpoolError}; /// Error statistics. +/// +/// NOTE: Due to imperfections of our world number of errors limited to [`std::u64::MAX`](https://doc.rust-lang.org/std/u64/constant.MAX.html). #[derive(Debug, Clone, Eq, PartialEq)] pub struct ErrorStatistics { /// I/O errors that occurred while issuing a read request pub read: u64, /// I/O errors that occurred while issuing a write request pub write: u64, - /// Checksum errors, meaning that the device returned corrupted data as the + /// Checksum errors, meaning the device returned corrupted data as the /// result of a read request pub checksum: u64, }