diff options
Diffstat (limited to 'tvix/nix-compat/src/nar/writer/mod.rs')
-rw-r--r-- | tvix/nix-compat/src/nar/writer/mod.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/tvix/nix-compat/src/nar/writer/mod.rs b/tvix/nix-compat/src/nar/writer/mod.rs index f73d323e3820..9abc2510d149 100644 --- a/tvix/nix-compat/src/nar/writer/mod.rs +++ b/tvix/nix-compat/src/nar/writer/mod.rs @@ -28,6 +28,7 @@ //! # Ok::<(), std::io::Error>(()) //! ``` +use bstr::ByteSlice; use std::io::{ self, BufRead, ErrorKind::{InvalidInput, UnexpectedEof}, @@ -73,11 +74,8 @@ impl<'a, 'w> Node<'a, 'w> { "target.len() > {}", wire::MAX_TARGET_LEN ); - debug_assert!( - !target.contains(&b'\0'), - "invalid target characters: {target:?}" - ); - debug_assert!(!target.is_empty(), "empty target"); + debug_assert!(!target.is_empty(), "target is empty"); + debug_assert!(!target.contains(&0), "target contains null byte"); self.write(&wire::TOK_SYM)?; self.write(&target.len().to_le_bytes())?; @@ -176,12 +174,11 @@ impl<'a, 'w> Directory<'a, 'w> { "name.len() > {}", wire::MAX_NAME_LEN ); - debug_assert!(name != b"", "name may not be empty"); - debug_assert!(name != b".", "invalid name: {name:?}"); - debug_assert!(name != b"..", "invalid name: {name:?}"); - - debug_assert!(!name.contains(&b'/'), "invalid name characters: {name:?}"); - debug_assert!(!name.contains(&b'\0'), "invalid name characters: {name:?}"); + debug_assert!(!name.is_empty(), "name is empty"); + debug_assert!(!name.contains(&0), "name contains null byte"); + debug_assert!(!name.contains(&b'/'), "name contains {:?}", '/'); + debug_assert!(name != b".", "name == {:?}", "."); + debug_assert!(name != b"..", "name == {:?}", ".."); match self.prev_name { None => { @@ -192,7 +189,9 @@ impl<'a, 'w> Directory<'a, 'w> { { assert!( &**_prev_name < name, - "misordered names: {_prev_name:?} >= {name:?}" + "misordered names: {:?} >= {:?}", + _prev_name.as_bstr(), + name.as_bstr() ); _prev_name.clear(); _prev_name.extend_from_slice(name); |