reproject: validate lon/lat shape parity in geoid_height and itrf_transform (#2026)#2028
Open
brendancol wants to merge 2 commits into
Open
reproject: validate lon/lat shape parity in geoid_height and itrf_transform (#2026)#2028brendancol wants to merge 2 commits into
brendancol wants to merge 2 commits into
Conversation
…nsform (#2026) Both public APIs ravel lon and lat independently and then index them in a numba @njit(parallel=True) kernel using lon.shape[0]. A shorter lat array used to silently read past its end and return wrong numbers without raising IndexError. Add an early shape check in geoid_height and itrf_transform that rejects mismatched lon and lat with a ValueError naming both shapes. For itrf_transform, also pre-empt non-broadcastable h shapes so the error message points at the public API rather than the broadcast call.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2026.
geoid_heightanditrf_transformravellonandlatseparately, then index them in a numba@njit(parallel=True)kernel usinglon.shape[0]. Iflatwas shorter thanlon, the kernel read past the end oflatand returned wrong numbers without raising. Both are public API, so the bug was invisible unless someone happened to test for it.This adds an early shape check in both functions that rejects mismatched
lonandlatwith aValueErrornaming both shapes.itrf_transformalso pre-empts non-broadcastablehshapes so the error points at the public API instead of the broadcast call.Spotted during the reproject security sweep on 2026-05-17 (Cat 4 OOB read plus Cat 6 missing input validation).
Test plan
pytest xrspatial/tests/test_reproject.py::TestGeoidShapeMismatch -v, 6 new tests, all passpytest xrspatial/tests/test_reproject.py::TestItrfShapeMismatch -v, 6 new tests, all passpytest xrspatial/tests/test_reproject.py -k "geoid or itrf", 57 tests, no regressions