aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-cell/fuzz/fuzz_targets/relaymsg.rs
blob: befd5a337159e3317567412c6b3cc1cb05faf1b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#![no_main]
use libfuzzer_sys::fuzz_target;
use tor_cell::{
    chancell::{BoxedCellBody, CELL_DATA_LEN},
    relaycell::{AnyRelayMsgOuter, RelayCellFormat},
};

fuzz_target!(|data: &[u8]| {
    let mut body: BoxedCellBody = Box::new([0_u8; CELL_DATA_LEN]);
    let copy_len = std::cmp::min(data.len(), body.len());
    body[..copy_len].copy_from_slice(&data[..copy_len]);
    let _ = AnyRelayMsgOuter::decode_singleton(RelayCellFormat::V0, body);
});