Fix fuzzer

This commit is contained in:
Simon Ask Ulsnes 2024-02-04 14:27:19 +01:00
parent 9b41218d0f
commit 417a4baccc
3 changed files with 13 additions and 15 deletions

View file

@ -1,18 +1,16 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use libyaml_safer::{
yaml_document_get_root_node, yaml_parser_load, yaml_parser_new, yaml_parser_set_input,
};
use libyaml_safer::{Document, Parser};
fuzz_target!(|data: &[u8]| fuzz_target(data));
fn fuzz_target(mut data: &[u8]) {
let mut parser = yaml_parser_new();
yaml_parser_set_input(&mut parser, &mut data);
let mut parser = Parser::new();
parser.set_input(&mut data);
while let Ok(mut document) = yaml_parser_load(&mut parser) {
let done = yaml_document_get_root_node(&mut document).is_none();
while let Ok(mut document) = Document::load(&mut parser) {
let done = document.get_root_node().is_none();
if done {
break;
}

View file

@ -1,15 +1,15 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use libyaml_safer::{yaml_parser_new, yaml_parser_parse, yaml_parser_set_input, EventData};
use libyaml_safer::{EventData, Parser};
fuzz_target!(|data: &[u8]| fuzz_target(data));
fn fuzz_target(mut data: &[u8]) {
let mut parser = yaml_parser_new();
yaml_parser_set_input(&mut parser, &mut data);
let mut parser = Parser::new();
parser.set_input(&mut data);
while let Ok(event) = yaml_parser_parse(&mut parser) {
while let Ok(event) = parser.parse() {
let is_end = matches!(event.data, EventData::StreamEnd);
if is_end {
break;

View file

@ -1,15 +1,15 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use libyaml_safer::{yaml_parser_new, yaml_parser_scan, yaml_parser_set_input, TokenData};
use libyaml_safer::{Scanner, TokenData};
fuzz_target!(|data: &[u8]| fuzz_target(data));
fn fuzz_target(mut data: &[u8]) {
let mut parser = yaml_parser_new();
yaml_parser_set_input(&mut parser, &mut data);
let mut scanner = Scanner::new();
scanner.set_input(&mut data);
while let Ok(token) = yaml_parser_scan(&mut parser) {
while let Ok(token) = Scanner::scan(&mut scanner) {
let is_end = matches!(token.data, TokenData::StreamEnd);
if is_end {
break;