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

Commitf684d71

Browse files
committed
OSS-Fuzz: Add new fuzzer upstream
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
1 parent9d5d794 commitf684d71

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-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: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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::{compose, canonical_combining_class, is_combining_mark, decompose_canonical, decompose_compatible},
12+
UnicodeNormalization,
13+
};
14+
15+
fuzz_target!(|data:&[u8]|{
16+
letmut data = data;
17+
let c =ifletSome((char_value, remaining_data)) = data.split_first(){
18+
match std::char::from_u32(*char_valueasu32){
19+
Some(ch) =>{
20+
data = remaining_data;
21+
ch
22+
}
23+
None =>return,
24+
}
25+
} else{
26+
return;
27+
};
28+
29+
// Generate second character for fuzzing if data is enough
30+
let c2 =ifletSome((char_value, remaining_data)) = data.split_first(){
31+
data = remaining_data;
32+
std::char::from_u32(*char_valueasu32)
33+
} else{
34+
None
35+
};
36+
let string_data:String = data.iter().filter_map(|&b| std::char::from_u32(basu32)).collect();
37+
38+
// Randomly choose a function target
39+
match data.first().map(|&b| b %10){
40+
Some(0) =>{
41+
ifletSome(c2) = c2{
42+
let _ = compose(c, c2);
43+
}
44+
}
45+
Some(1) =>{
46+
let _ = canonical_combining_class(c);
47+
}
48+
Some(2) =>{
49+
let _ = is_combining_mark(c);
50+
}
51+
Some(3) =>{
52+
let _ = string_data.nfc().collect::<String>();
53+
}
54+
Some(4) =>{
55+
let _ = string_data.nfkd().collect::<String>();
56+
}
57+
Some(5) =>{
58+
let _ = string_data.nfd().collect::<String>();
59+
}
60+
Some(6) =>{
61+
let _ = string_data.nfkc().collect::<String>();
62+
}
63+
Some(7) =>{
64+
let _ = string_data.stream_safe().collect::<String>();
65+
}
66+
Some(8) =>{
67+
decompose_canonical(c, |_|{});
68+
}
69+
Some(9) =>{
70+
decompose_compatible(c, |_|{});
71+
}
72+
_ =>{}
73+
}
74+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp