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

Commit9b20974

Browse files
authored
Merge pull request#107 from arthurscchan/new-fuzzer
OSS-Fuzz: Add new fuzzer upstream
2 parents9d5d794 +ac1c634 commit9b20974

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

‎fuzz/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ path = "fuzz_targets/streaming.rs"
2323
test =false
2424
doc =false
2525

26+
[[bin]]
27+
name ="process"
28+
path ="fuzz_targets/process.rs"
29+
test =false
30+
doc =false
31+
2632
# Work around https://github.com/rust-lang/cargo/issues/8338
2733
[workspace]

‎fuzz/fuzz_targets/process.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// The fuzzing harness fuzz test some of the the
2+
// unicode string normalization processing
3+
4+
#![no_main]
5+
6+
#[macro_use]
7+
externcrate libfuzzer_sys;
8+
externcrate unicode_normalization;
9+
10+
use unicode_normalization::{
11+
char::{
12+
canonical_combining_class, compose, decompose_canonical, decompose_compatible,
13+
is_combining_mark,
14+
},
15+
UnicodeNormalization,
16+
};
17+
18+
fuzz_target!(|data:(u8,String)|{
19+
let(function_index, string_data) = data;
20+
21+
// Create an iterator for characters
22+
letmut chars = string_data.chars();
23+
24+
// Randomly fuzz a target function
25+
match function_index %10{
26+
0 =>{
27+
// Fuzz compose with two distinct characters
28+
iflet(Some(c1),Some(c2)) =(chars.next(), chars.next()){
29+
let _ = compose(c1, c2);
30+
}
31+
}
32+
1 =>{
33+
// Fuzz canonical_combining_class
34+
ifletSome(c) = chars.next(){
35+
let _ = canonical_combining_class(c);
36+
}
37+
}
38+
2 =>{
39+
// Fuzz is_combining_mark
40+
ifletSome(c) = chars.next(){
41+
let _ = is_combining_mark(c);
42+
}
43+
}
44+
3 =>{
45+
// Fuzz NFC
46+
let _ = string_data.nfc().collect::<String>();
47+
}
48+
4 =>{
49+
// Fuzz NFKD
50+
let _ = string_data.nfkd().collect::<String>();
51+
}
52+
5 =>{
53+
// Fuzz NFD
54+
let _ = string_data.nfd().collect::<String>();
55+
}
56+
6 =>{
57+
// Fuzz NFKC
58+
let _ = string_data.nfkc().collect::<String>();
59+
}
60+
7 =>{
61+
// Fuzz stream_safe
62+
let _ = string_data.stream_safe().collect::<String>();
63+
}
64+
8 =>{
65+
// Fuzz decompose_canonical
66+
ifletSome(c) = chars.next(){
67+
decompose_canonical(c, |_|{});
68+
}
69+
}
70+
9 =>{
71+
// Fuzz decompose_compatible
72+
ifletSome(c) = chars.next(){
73+
decompose_compatible(c, |_|{});
74+
}
75+
}
76+
_ =>{}
77+
}
78+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp