//! The routing table's own reading of attribute bytes. A set is kept as //! the bytes it came in, and what selection and validation need (the //! path, the origin, the next hop) is read straight from them, by code //! other than the decoder's. Nothing a peer sends may make that panic, //! and what it reads must be what the decoder would have read. #![no_main] use bgp_rib::table::AttrStore; use libfuzzer_sys::fuzz_target; fuzz_target!(|data: &[u8]| { let store = AttrStore::new(); let Some(set) = store.intern_wire(data) else { return; }; let key = set.key(); let mut path = Vec::new(); let has_set = set.as_path(&mut path); let _ = set.next_hop(); // The origin is the path's last AS, unless a set is in the way. if let Some(origin) = key.origin() { assert_eq!(path.last(), Some(&origin)); } if !has_set { assert_eq!(usize::from(key.as_path_len), path.len()); } // The same bytes are the same set. let again = store.intern_wire(data).expect("it was a set a moment ago"); assert!(std::sync::Arc::ptr_eq(&set, &again)); let _ = set.attributes(); });