aboutsummaryrefslogtreecommitdiff
path: root/fuzzer/README.md
blob: 97e42816cd146ef201adefbe1b0db5a73698602f (plain)
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
# Fuzzer for libxaac decoder

This describes steps to build xaac_dec_fuzzer binary.

## Linux x86/x64

###  Requirements
- cmake (3.5 or above)
- make
- clang (6.0 or above)
  needs to support -fsanitize=fuzzer, -fsanitize=fuzzer-no-link

### Steps to build
Clone libxaac repository
```
$ git clone https://android.googlesource.com/platform/external/libxaac
```
Create a directory inside libxaac and change directory
```
 $ cd libxaac
 $ mkdir build
 $ cd build
```

Build fuzzer with required sanitizers (-DSANITIZE=fuzzer-no-link is mandatory to enable fuzzers)
```
 $ cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
   -DCMAKE_BUILD_TYPE=Debug -DSANITIZE=fuzzer-no-link,address,\
   signed-integer-overflow,unsigned-integer-overflow
 $ make
```

### Steps to run
Create a directory CORPUS_DIR and copy some elementary aac files to that folder
To run the fuzzer
```
$ ./xaac_dec_fuzzer CORPUS_DIR
```

## Android

### Steps to build
Build the fuzzer
```
  $ SANITIZE_TARGET=address SANITIZE_HOST=address mmma -j$(nproc) \
    external/libxaac/fuzzer
```

### Steps to run
Create a directory CORPUS_DIR and copy some elementary aac files to that folder
Push this directory to device.

To run on device
```
  $ adb sync data
  $ adb shell /data/fuzz/xaac_dec_fuzzer CORPUS_DIR
```
To run on host
```
  $ $ANDROID_HOST_OUT/fuzz/xaac_dec_fuzzer CORPUS_DIR
```

## References:
 * http://llvm.org/docs/LibFuzzer.html
 * https://github.com/google/oss-fuzz