-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add polygonToCellsNoHoles fuzzer #557
Merged
isaacbrodsky
merged 36 commits into
uber:master
from
isaacbrodsky:llvm-fuzzer-polygon-to-cells-2
Jan 23, 2022
Merged
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
0277ce5
Add LLVM fuzzer harness
1c8ec2e
Add AFL++ test case generator
b89c76b
Fuzz more gridDisk functions
79d2e2c
add fuzzerH3SetToLinkedGeo
a28a807
Add more fuzzers
9445cbb
Additional fuzzers
f971dcf
add fuzzerVertexes
e0c8841
Add test-fuzzer script
007b7c3
Fix linux build
02abb99
Fix fuzzerIndexIO
caedc90
test-fuzzer use subshell for ls
isaacbrodsky de5a2c3
Update test-fuzzer again
isaacbrodsky 8bbc36a
Fix test-fuzzer again
isaacbrodsky 021c994
fuzzerCompact
2195863
Update readme
4a65123
libFuzzer tests
1e7066e
reformat header
0ede718
README updates
65b4ef3
fuzzerDirectedEdge
79b1f44
fuzzerLocalIj
25360ef
fix fuzzerDirectedEdge build
ac4b918
Fix fuzzer programs
isaacbrodsky 1145bce
remove logging
isaacbrodsky cd14266
remove h3Println
isaacbrodsky 76532d8
add fuzzerPoylgonToCells
isaacbrodsky 84bc4e9
Update per review
323d9e9
Merge branch 'master' into llvm-fuzzer-harness
e04c62c
Add comment on memcpy per review
0016f1c
Fix potential crash in vertexRotations
7807131
Merge branch 'master' into llvm-fuzzer-harness
4b4e623
Catch possible failure in getIcosahedronFaces
d501e51
Don't assert specific error in testVertex
d326156
Add polygonToCellsNoHoles fuzzer
558a37f
fix formatting
ffc3545
Merge branch 'master' into llvm-fuzzer-polygon-to-cells-2
c20e860
Mainly comment only changes
isaacbrodsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2022 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** @file | ||
* @brief Fuzzer program for polygonToCells and related functions, without holes | ||
*/ | ||
|
||
#include "aflHarness.h" | ||
#include "h3api.h" | ||
#include "utility.h" | ||
|
||
const int MAX_RES = 15; | ||
const int MAX_SZ = 4000000; | ||
|
||
void run(GeoPolygon *geoPolygon, int res) { | ||
int64_t sz; | ||
H3Error err = H3_EXPORT(maxPolygonToCellsSize)(geoPolygon, res, &sz); | ||
if (!err && sz < MAX_SZ) { | ||
if (sz < 0) { | ||
// TODO: Check on this once rebased | ||
printf("Oh no - sz is negative\n"); | ||
} | ||
H3Index *out = calloc(sz, sizeof(H3Index)); | ||
H3_EXPORT(polygonToCells)(geoPolygon, res, out); | ||
free(out); | ||
} | ||
} | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | ||
if (size < sizeof(int)) { | ||
return 0; | ||
} | ||
|
||
uint8_t res = *data; | ||
size_t vertsSize = size - 1; | ||
int numVerts = vertsSize / sizeof(LatLng); | ||
|
||
GeoPolygon geoPolygon; | ||
geoPolygon.numHoles = 0; | ||
geoPolygon.holes = NULL; | ||
geoPolygon.geoloop.numVerts = numVerts; | ||
geoPolygon.geoloop.verts = (LatLng *)(data + 1); | ||
|
||
run(&geoPolygon, res); | ||
|
||
return 0; | ||
} | ||
|
||
AFL_HARNESS_MAIN(sizeof(H3Index) * 1024); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my info - why
+ 1
? Oh, because the firstuint_8
is the res? Might be worth a comment.I imagine that most fuzzer runs would error quickly on an invalid
res
here, and never exercise the polyfill...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still better than fuzzerPoylgonToCells.c which is very difficult for the fuzzer to make progress on; here it only needs to guess one byte correctly (polygonToCells actually takes an int but I don't think that's quite as relevant) which I believe is very doable.