ieee802154_header.rs 852 B

12345678910111213141516171819
  1. #![no_main]
  2. use libfuzzer_sys::fuzz_target;
  3. use smoltcp::wire::{Ieee802154Frame, Ieee802154Repr};
  4. fuzz_target!(|data: &[u8]| {
  5. if let Ok(ref frame) = Ieee802154Frame::new_checked(data) {
  6. if let Ok(repr) = Ieee802154Repr::parse(frame) {
  7. // The buffer len returns only the length required for emitting the header
  8. // and does not take into account the length of the payload.
  9. let mut buffer = vec![0; repr.buffer_len()];
  10. // NOTE: unchecked because the checked version checks if the addressing mode field
  11. // is valid or not. The addressing mode field is required for calculating the length of
  12. // the header, which is used in `check_len`.
  13. let mut frame = Ieee802154Frame::new_unchecked(&mut buffer[..]);
  14. repr.emit(&mut frame);
  15. }
  16. };
  17. });