fuzz_target_1.rs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #![no_main]
  2. use libfuzzer_sys::fuzz_target;
  3. extern crate aml;
  4. use std::sync::atomic::{AtomicBool, Ordering};
  5. static INITIALIZED: AtomicBool = AtomicBool::new(false);
  6. fuzz_target!(|data: &[u8]| {
  7. if let Ok(false) = INITIALIZED.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed) {
  8. simplelog::SimpleLogger::init(simplelog::LevelFilter::Trace, simplelog::Config::default()).unwrap();
  9. }
  10. let mut context = aml::AmlContext::new(Box::new(Handler), false, aml::DebugVerbosity::None);
  11. let _ = context.parse_table(data);
  12. });
  13. struct Handler;
  14. impl aml::Handler for Handler {
  15. fn read_u8(&self, _address: usize) -> u8 {
  16. 0
  17. }
  18. fn read_u16(&self, _address: usize) -> u16 {
  19. 0
  20. }
  21. fn read_u32(&self, _address: usize) -> u32 {
  22. 0
  23. }
  24. fn read_u64(&self, _address: usize) -> u64 {
  25. 0
  26. }
  27. fn write_u8(&mut self, _address: usize, _value: u8) {}
  28. fn write_u16(&mut self, _address: usize, _value: u16) {}
  29. fn write_u32(&mut self, _address: usize, _value: u32) {}
  30. fn write_u64(&mut self, _address: usize, _value: u64) {}
  31. fn read_io_u8(&self, _port: u16) -> u8 {
  32. 0
  33. }
  34. fn read_io_u16(&self, _port: u16) -> u16 {
  35. 0
  36. }
  37. fn read_io_u32(&self, _port: u16) -> u32 {
  38. 0
  39. }
  40. fn write_io_u8(&self, _port: u16, _value: u8) {}
  41. fn write_io_u16(&self, _port: u16, _value: u16) {}
  42. fn write_io_u32(&self, _port: u16, _value: u32) {}
  43. fn read_pci_u8(&self, _segment: u16, _bus: u8, _device: u8, _function: u8, _offset: u16) -> u8 {
  44. 0
  45. }
  46. fn read_pci_u16(&self, _segment: u16, _bus: u8, _device: u8, _function: u8, _offset: u16) -> u16 {
  47. 0
  48. }
  49. fn read_pci_u32(&self, _segment: u16, _bus: u8, _device: u8, _function: u8, _offset: u16) -> u32 {
  50. 0
  51. }
  52. fn write_pci_u8(&self, _segment: u16, _bus: u8, _device: u8, _function: u8, _offset: u16, _value: u8) {}
  53. fn write_pci_u16(&self, _segment: u16, _bus: u8, _device: u8, _function: u8, _offset: u16, _value: u16) {}
  54. fn write_pci_u32(&self, _segment: u16, _bus: u8, _device: u8, _function: u8, _offset: u16, _value: u32) {}
  55. }