1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
Building fuzzers for libultrahdr
================================
### Requirements
- Refer [Requirements](../README.md#Requirements)
- Additionally compilers are required to support options *-fsanitize=fuzzer, -fsanitize=fuzzer-no-link*.
For instance, clang 12 (or later)
### Building Commands
mkdir {build_directory}
cd {build_directory}
cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUHDR_BUILD_FUZZERS=1
make
This will generate the following files under *{build_directory}*:
**libultrahdr.a**<br> Instrumented ultrahdr library
**ultrahdr_enc_fuzzer**<br> ultrahdr encoder fuzzer
**ultrahdr_dec_fuzzer**<br> ultrahdr decoder fuzzer
Additionally, while building fuzzers, user can enable sanitizers by providing desired
sanitizer option(s) through UHDR_SANITIZE_OPTIONS.
To enable ASan,
cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DUHDR_BUILD_FUZZERS=1 -DUHDR_SANITIZE_OPTIONS=address
make
To enable MSan,
cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DUHDR_BUILD_FUZZERS=1 -DUHDR_SANITIZE_OPTIONS=memory
make
To enable TSan,
cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DUHDR_BUILD_FUZZERS=1 -DUHDR_SANITIZE_OPTIONS=thread
make
To enable UBSan,
cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DUHDR_BUILD_FUZZERS=1 -DUHDR_SANITIZE_OPTIONS=undefined
make
UBSan can be grouped with ASan, MSan or TSan.
For example, to enable ASan and UBSan,
cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DUHDR_BUILD_FUZZERS=1 -DUHDR_SANITIZE_OPTIONS=address,undefined
make
### Running
To run the fuzzer(s), first create a corpus directory that holds the initial
"seed" sample inputs. For decoder fuzzer, ultrahdr jpeg images can be used and
for encoder fuzzer, sample yuv files can be used.
Then run the fuzzers on the corpus directory.
mkdir CORPUS_DIR
cp seeds/* CORPUS_DIR
./ultrahdr_dec_fuzzer CORPUS_DIR
./ultrahdr_enc_fuzzer CORPUS_DIR
|