From 417a4baccc36da8cdfdaae592da7ca5ee38ea8d1 Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Sun, 4 Feb 2024 14:27:19 +0100 Subject: [PATCH] Fix fuzzer --- fuzz/fuzz_targets/load.rs | 12 +++++------- fuzz/fuzz_targets/parse.rs | 8 ++++---- fuzz/fuzz_targets/scan.rs | 8 ++++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/fuzz/fuzz_targets/load.rs b/fuzz/fuzz_targets/load.rs index 21ef759..aae10fa 100644 --- a/fuzz/fuzz_targets/load.rs +++ b/fuzz/fuzz_targets/load.rs @@ -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; } diff --git a/fuzz/fuzz_targets/parse.rs b/fuzz/fuzz_targets/parse.rs index 1e73633..ff1995e 100644 --- a/fuzz/fuzz_targets/parse.rs +++ b/fuzz/fuzz_targets/parse.rs @@ -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; diff --git a/fuzz/fuzz_targets/scan.rs b/fuzz/fuzz_targets/scan.rs index 791697e..86bd738 100644 --- a/fuzz/fuzz_targets/scan.rs +++ b/fuzz/fuzz_targets/scan.rs @@ -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;