diff --git a/age/src/format.rs b/age/src/format.rs index ac83331..7b5bb31 100644 --- a/age/src/format.rs +++ b/age/src/format.rs @@ -298,7 +298,7 @@ mod write { pub(super) fn header<'a, W: 'a + Write>(h: &'a Header) -> impl SerializeFn + 'a { move |w: WriteContext| match h { Header::V1(v1) => header_v1(v1)(w), - Header::Unknown(version) => panic!("Cannot write header for version {}", version), + Header::Unknown(version) => tuple((slice(AGE_MAGIC), slice(version), string("\n")))(w), } } } diff --git a/age/src/lib.rs b/age/src/lib.rs index d2d3d0e..d306bac 100644 --- a/age/src/lib.rs +++ b/age/src/lib.rs @@ -127,12 +127,8 @@ pub mod cli_common; #[cfg(fuzzing)] pub fn fuzz_header(data: &[u8]) { if let Ok(header) = format::Header::read(data) { - if let format::Header::Unknown(_) = header { - // Unknown headers cause panics on write. - } else { - let mut buf = Vec::with_capacity(data.len()); - header.write(&mut buf).expect("can write header"); - assert_eq!(&buf[..], &data[..buf.len()]); - } + let mut buf = Vec::with_capacity(data.len()); + header.write(&mut buf).expect("can write header"); + assert_eq!(&buf[..], &data[..buf.len()]); } }