/src/binutils-gdb/binutils/fuzz_nm.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright 2021 Google LLC |
2 | | Licensed under the Apache License, Version 2.0 (the "License"); |
3 | | you may not use this file except in compliance with the License. |
4 | | You may obtain a copy of the License at |
5 | | http://www.apache.org/licenses/LICENSE-2.0 |
6 | | Unless required by applicable law or agreed to in writing, software |
7 | | distributed under the License is distributed on an "AS IS" BASIS, |
8 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
9 | | See the License for the specific language governing permissions and |
10 | | limitations under the License. |
11 | | */ |
12 | | |
13 | | /* |
14 | | * We convert nm.c into a header file to make convenient for fuzzing. |
15 | | * We do this for several of the binutils applications when creating |
16 | | * the binutils fuzzers. |
17 | | */ |
18 | | #include "fuzz_nm.h" |
19 | | |
20 | | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); |
21 | | int |
22 | | LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
23 | 117k | { |
24 | 117k | char filename[256]; |
25 | 117k | sprintf(filename, "/tmp/libfuzzer.%d", getpid()); |
26 | 117k | FILE *fp = fopen(filename, "wb"); |
27 | 117k | if (!fp) { |
28 | 0 | return 0; |
29 | 0 | } |
30 | 117k | fwrite(data, size, 1, fp); |
31 | 117k | fclose(fp); |
32 | | |
33 | | // Globals |
34 | 117k | line_numbers = 1; |
35 | 117k | no_sort = 0; |
36 | 117k | sort_numerically = 1; |
37 | 117k | sort_by_size = 0; |
38 | 117k | filename_per_symbol = 1; |
39 | | |
40 | | |
41 | | // Main fuzz entrypoint in nm.c |
42 | 117k | display_file(filename); |
43 | | |
44 | 117k | unlink(filename); |
45 | 117k | return 0; |
46 | 117k | } |