Coverage Report

Created: 2026-02-23 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/h3/src/apps/fuzzers/fuzzerInternalCoordIjk.c
Line
Count
Source
1
/*
2
 * Copyright 2022 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 internal functions in coordijk.c
18
 */
19
20
#include "aflHarness.h"
21
#include "algos.h"
22
#include "h3api.h"
23
#include "utility.h"
24
25
typedef struct {
26
    CoordIJK ijk;
27
} inputArgs;
28
29
907
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
30
907
    if (size < sizeof(inputArgs)) {
31
6
        return 0;
32
6
    }
33
901
    const inputArgs *args = (const inputArgs *)data;
34
35
    // These functions require that input be non-negative
36
901
    if (args->ijk.i >= 0 && args->ijk.j >= 0 && args->ijk.k >= 0) {
37
658
        CoordIJK ijkCopy1 = args->ijk;
38
658
        _upAp7Checked(&ijkCopy1);
39
658
        CoordIJK ijkCopy2 = args->ijk;
40
658
        _upAp7rChecked(&ijkCopy2);
41
658
    }
42
    // This function needs a guard check to be safe and that guard
43
    // check assumes k = 0.
44
901
    CoordIJK ijkCopy3 = args->ijk;
45
901
    ijkCopy3.k = 0;
46
901
    if (!_ijkNormalizeCouldOverflow(&ijkCopy3)) {
47
828
        _ijkNormalize(&ijkCopy3);
48
828
    }
49
50
901
    return 0;
51
907
}
52
53
AFL_HARNESS_MAIN(sizeof(inputArgs));