Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seq: fuzz PreciseNumber::from_str #6183

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/fuzzing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
- { name: fuzz_parse_glob, should_pass: true }
- { name: fuzz_parse_size, should_pass: true }
- { name: fuzz_parse_time, should_pass: true }
- { name: fuzz_seq_parse_number, should_pass: true }

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
Expand Down
6 changes: 6 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ path = "fuzz_targets/fuzz_test.rs"
test = false
doc = false

[[bin]]
name = "fuzz_seq_parse_number"
path = "fuzz_targets/fuzz_seq_parse_number.rs"
test = false
doc = false

[[bin]]
name = "fuzz_parse_glob"
path = "fuzz_targets/fuzz_parse_glob.rs"
Expand Down
15 changes: 15 additions & 0 deletions fuzz/fuzz_targets/fuzz_seq_parse_number.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
#![no_main]

use libfuzzer_sys::fuzz_target;
use std::str::FromStr;
use uu_seq::number::PreciseNumber;

fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
let _ = PreciseNumber::from_str(s);
}
});
4 changes: 4 additions & 0 deletions src/uu/seq/src/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ use uucore::{format_usage, help_about, help_usage};

mod error;
mod extendedbigdecimal;
// public to allow fuzzing
#[cfg(fuzzing)]
pub mod number;
#[cfg(not(fuzzing))]
mod number;
mod numberparse;
use crate::error::SeqError;
Expand Down
Loading