fix: prevent StackOverflowError from deeply nested GeometryCollection in GeoJsonParser#1699
fix: prevent StackOverflowError from deeply nested GeometryCollection in GeoJsonParser#1699ZeroX-404 wants to merge 4 commits into
Conversation
Add MAX_GEOMETRY_DEPTH = 20 limit to parseGeometry() to prevent StackOverflowError when parsing malicious GeoJSON with deeply nested GeometryCollection objects. Geometries exceeding the depth limit are silently ignored and a warning is logged via Log.w().
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Hi maintainers, could someone please review this fix? I verified that it prevents the StackOverflowError caused by deeply nested GeometryCollections. |
|
Hi @dkhawk, gentle follow up — could you take a look when you have a moment? Happy to adjust anything. Thanks! |
Add three tests to GeoJsonParserTest to verify the fix for StackOverflowError caused by deeply nested GeometryCollection objects (introduced in the accompanying fix commit): - testDeeplyNestedGeometryCollection_doesNotThrowStackOverflow: Ensures parsing 2000-level nesting no longer throws StackOverflowError - testGeometryBeyondMaxDepth_returnsNull: Ensures geometry exceeding MAX_GEOMETRY_DEPTH (20) returns null instead of crashing - testShallowNestedGeometryCollection_parsedCorrectly: Ensures normal shallow nesting still parses correctly (regression guard) Relates to: googlemaps#1699
|
Hi @dkhawk, I've updated the PR with unit tests covering the depth-limit behavior:
Happy to adjust anything if needed. Thanks! |
Thank you for your contribution! And sorry for the delay in reviewing it as I have been away. BTW, this version of code is slated to be replaced soon. We have a complete rewrite in https://github.com/googlemaps/android-maps-utils/tree/feat/rewrite-android-maps-utils. We have put out the first RC and expect RC2 soon. I'll see if the problem also exists in that rewrite. |
…ded by dkhawk's commit
8bb2c5b to
f37823d
Compare
|
Hi @dkhawk, I've applied your suggested changes — countdown maxDepth logic and updated test assertions. All tests pass locally. Ready for merge whenever you are! |
Description:
parseGeometry()
→ createGeometry()
→ createGeometryCollection()
→ parseGeometry() // unbounded recursion