/src/h3/src/apps/fuzzers/fuzzerCellProperties.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2021 Uber Technologies, Inc. |
3 | | * |
4 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | * you may not use this file except in compliance with the License. |
6 | | * You may obtain a copy of the License at |
7 | | * |
8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | * |
10 | | * Unless required by applicable law or agreed to in writing, software |
11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | * See the License for the specific language governing permissions and |
14 | | * limitations under the License. |
15 | | */ |
16 | | /** @file |
17 | | * @brief Fuzzer program for cell property functions |
18 | | */ |
19 | | |
20 | | #include "aflHarness.h" |
21 | | #include "h3api.h" |
22 | | #include "utility.h" |
23 | | |
24 | | typedef struct { |
25 | | H3Index index; |
26 | | H3Index mask; |
27 | | int res; |
28 | | } inputArgs; |
29 | | |
30 | 660 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
31 | 660 | if (size < sizeof(inputArgs)) { |
32 | 8 | return 0; |
33 | 8 | } |
34 | 652 | const inputArgs *args = (const inputArgs *)data; |
35 | | |
36 | 652 | H3_EXPORT(getResolution)(args->index); |
37 | 652 | H3_EXPORT(getBaseCellNumber)(args->index); |
38 | 652 | H3_EXPORT(isValidIndex)(args->index); |
39 | 652 | H3_EXPORT(isValidCell)(args->index); |
40 | 652 | H3_EXPORT(isPentagon)(args->index); |
41 | 652 | H3_EXPORT(isResClassIII)(args->index); |
42 | | |
43 | 652 | int faceCount; |
44 | 652 | H3Error err = H3_EXPORT(maxFaceCount)(args->index, &faceCount); |
45 | 652 | if (!err && faceCount > 0) { |
46 | 652 | int *out = calloc(faceCount, sizeof(int)); |
47 | 652 | H3_EXPORT(getIcosahedronFaces)(args->index, out); |
48 | 652 | free(out); |
49 | 652 | } |
50 | | |
51 | 652 | int digitOut; |
52 | 652 | H3_EXPORT(getIndexDigit)(args->index, args->res, &digitOut); |
53 | | |
54 | 652 | return 0; |
55 | 660 | } |
56 | | |
57 | | AFL_HARNESS_MAIN(sizeof(inputArgs)); |