From b5753af707f40ef3a2976a85aab3c233400e8112 Mon Sep 17 00:00:00 2001 From: DGonzalezVillal Date: Thu, 29 Jan 2026 17:44:29 +0000 Subject: [PATCH] feat: introduce unsafe_parser When this feature is enabled, the zero-byte check performed by skip_bytes is disabled. As a result, parsing will no longer fail when fields that are expected to be zero contain non-zero values. This enables forward compatibility when reserved fields are repurposed in new report versions. Users enabling this feature must take care to validate reserved fields manually if they rely on their contents for security or correctness. Signed-off-by: DGonzalezVillal --- Cargo.toml | 1 + src/util/parser_helper/read_ext.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 0858b3c4..251c4c76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ sev = ["dep:rdrand"] snp = [] crypto_nossl = ["dep:p384", "dep:rsa", "dep:sha2", "dep:x509-cert"] serde = ["dep:serde", "dep:serde-big-array", "dep:serde_bytes"] +unsafe_parser = [] [target.'cfg(target_os = "linux")'.dependencies] iocuddle = "^0.1" diff --git a/src/util/parser_helper/read_ext.rs b/src/util/parser_helper/read_ext.rs index dc7e4fcb..1d88d64c 100644 --- a/src/util/parser_helper/read_ext.rs +++ b/src/util/parser_helper/read_ext.rs @@ -33,6 +33,7 @@ pub trait ReadExt: Read { while remaining > 0 { let n = remaining.min(CHUNK); self.read_exact(&mut buf[..n])?; + #[cfg(not(feature = "unsafe_parser"))] if buf[..n].iter().any(|&b| b != 0) { return Err(std::io::Error::new( std::io::ErrorKind::InvalidData,