//! A message body behind a correct header, so that the fuzzer spends its //! time in the OPEN, UPDATE and NOTIFICATION parsers and not on guessing //! the marker and length. The first byte picks the message type and what //! the session settled: see `bgp_fuzz::Session`. #![no_main] use libfuzzer_sys::fuzz_target; /// The longest body that fits a BGP message (4096 less the 19-byte header). const MAX_BODY: usize = 4096 - 19; fuzz_target!(|data: &[u8]| { let Some((selector, body)) = data.split_first() else { return; }; let body = &body[..body.len().min(MAX_BODY)]; // Bits 1 to 3; the others pick the session. let msg_type = 1 + ((selector >> 1) & 0x07) % 5; let mut wire = vec![0xff; 16]; wire.extend_from_slice(&((19 + body.len()) as u16).to_be_bytes()); wire.push(msg_type); wire.extend_from_slice(body); bgp_fuzz::decode_and_check(bgp_fuzz::Session::from_bits(*selector), &wire); });