dhcp_header.rs 624 B

12345678910111213141516171819
  1. #![no_main]
  2. use libfuzzer_sys::fuzz_target;
  3. use smoltcp::wire::{DhcpPacket, DhcpRepr};
  4. fuzz_target!(|data: &[u8]| {
  5. let _ = match DhcpPacket::new_checked(data) {
  6. Ok(ref packet) => match DhcpRepr::parse(packet) {
  7. Ok(dhcp_repr) => {
  8. let mut dhcp_payload = vec![0; dhcp_repr.buffer_len()];
  9. match DhcpPacket::new_checked(&mut dhcp_payload[..]) {
  10. Ok(mut dhcp_packet) => Some(dhcp_repr.emit(&mut dhcp_packet)),
  11. Err(_) => None,
  12. }
  13. }
  14. Err(_) => None,
  15. },
  16. Err(_) => None,
  17. };
  18. });