Skip to content

Commit a9c0a2e

Browse files
authored
add fuzzer for cellsToMultiPolygon (#1122)
1 parent 2c99a6e commit a9c0a2e

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ set(OTHER_SOURCE_FILES
295295
src/apps/fuzzers/fuzzerLatLngToCell.c
296296
src/apps/fuzzers/fuzzerCellToLatLng.c
297297
src/apps/fuzzers/fuzzerGridDisk.c
298+
src/apps/fuzzers/fuzzerCellsToMultiPolygon.c
298299
src/apps/fuzzers/fuzzerCellsToLinkedMultiPolygon.c
299300
src/apps/fuzzers/fuzzerDistances.c
300301
src/apps/fuzzers/fuzzerCellArea.c
@@ -622,6 +623,8 @@ if(BUILD_FUZZERS)
622623
add_h3_fuzzer(fuzzerLatLngToCell src/apps/fuzzers/fuzzerLatLngToCell.c)
623624
add_h3_fuzzer(fuzzerCellToLatLng src/apps/fuzzers/fuzzerCellToLatLng.c)
624625
add_h3_fuzzer(fuzzerGridDisk src/apps/fuzzers/fuzzerGridDisk.c)
626+
add_h3_fuzzer(fuzzerCellsToMultiPolygon
627+
src/apps/fuzzers/fuzzerCellsToMultiPolygon.c)
625628
add_h3_fuzzer(fuzzerCellsToLinkedMultiPolygon
626629
src/apps/fuzzers/fuzzerCellsToLinkedMultiPolygon.c)
627630
add_h3_fuzzer(fuzzerDistances src/apps/fuzzers/fuzzerDistances.c)

src/apps/fuzzers/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ The public API of H3 is covered in the following fuzzers:
2424
| cellToParent | [fuzzerHierarchy](./fuzzerHierarchy.c)
2525
| cellToVertex | [fuzzerVertexes](./fuzzerVertexes.c)
2626
| cellToVertexes | [fuzzerVertexes](./fuzzerVertexes.c)
27+
| cellsToMultiPolygon | [fuzzerCellsToMultiPolygon.c](./fuzzerCellsToMultiPolygon.c)
28+
| cellsToLinkedMultiPolygon | [fuzzerCellsToLinkedMultiPolygon.c](./fuzzerCellsToLinkedMultiPolygon.c)
2729
| cellsToDirectedEdge | [fuzzerDirectedEdge](./fuzzerDirectedEdge.c)
2830
| childPosToCell| [fuzzerCellToChildPos](./fuzzerCellToChildPos.c)
2931
| compactCells | [fuzzerCompact](./fuzzerCompact.c)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2026 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 cellsToMultiPolygon
18+
*/
19+
20+
#include "aflHarness.h"
21+
#include "h3api.h"
22+
#include "utility.h"
23+
24+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
25+
const H3Index *h3Set = (const H3Index *)data;
26+
int sz = size / sizeof(H3Index);
27+
28+
GeoMultiPolygon polygon;
29+
H3Error err = H3_EXPORT(cellsToMultiPolygon)(h3Set, sz, &polygon);
30+
31+
if (!err) {
32+
H3_EXPORT(destroyGeoMultiPolygon)(&polygon);
33+
}
34+
return 0;
35+
}
36+
37+
AFL_HARNESS_MAIN(sizeof(H3Index) * 1024);

0 commit comments

Comments
 (0)