Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

OSS-Fuzz: Add new fuzzer upstream#107

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Manishearth merged 3 commits intounicode-rs:masterfromarthurscchan:new-fuzzer
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
6 changes: 6 additions & 0 deletionsfuzz/Cargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,5 +23,11 @@ path = "fuzz_targets/streaming.rs"
test = false
doc = false

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

# Work around https://github.com/rust-lang/cargo/issues/8338
[workspace]
78 changes: 78 additions & 0 deletionsfuzz/fuzz_targets/process.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
// The fuzzing harness fuzz test some of the the
// unicode string normalization processing

#![no_main]

#[macro_use]
extern crate libfuzzer_sys;
extern crate unicode_normalization;

use unicode_normalization::{
char::{
canonical_combining_class, compose, decompose_canonical, decompose_compatible,
is_combining_mark,
},
UnicodeNormalization,
};

fuzz_target!(|data: (u8, String)| {
let (function_index, string_data) = data;

// Create an iterator for characters
let mut chars = string_data.chars();

// Randomly fuzz a target function
match function_index % 10 {
0 => {
// Fuzz compose with two distinct characters
if let (Some(c1), Some(c2)) = (chars.next(), chars.next()) {
let _ = compose(c1, c2);
}
}
1 => {
// Fuzz canonical_combining_class
if let Some(c) = chars.next() {
let _ = canonical_combining_class(c);
}
}
2 => {
// Fuzz is_combining_mark
if let Some(c) = chars.next() {
let _ = is_combining_mark(c);
}
}
3 => {
// Fuzz NFC
let _ = string_data.nfc().collect::<String>();
}
4 => {
// Fuzz NFKD
let _ = string_data.nfkd().collect::<String>();
}
5 => {
// Fuzz NFD
let _ = string_data.nfd().collect::<String>();
}
6 => {
// Fuzz NFKC
let _ = string_data.nfkc().collect::<String>();
}
7 => {
// Fuzz stream_safe
let _ = string_data.stream_safe().collect::<String>();
}
8 => {
// Fuzz decompose_canonical
if let Some(c) = chars.next() {
decompose_canonical(c, |_| {});
}
}
9 => {
// Fuzz decompose_compatible
if let Some(c) = chars.next() {
decompose_compatible(c, |_| {});
}
}
_ => {}
}
});
Loading

[8]ページ先頭

©2009-2025 Movatter.jp