Add geotiff edge-case tests: IFD loops, header parsing, descending-y, non-georeferenced (#1482)#1492
Open
brendancol wants to merge 1 commit intomainfrom
Open
Add geotiff edge-case tests: IFD loops, header parsing, descending-y, non-georeferenced (#1482)#1492brendancol wants to merge 1 commit intomainfrom
brendancol wants to merge 1 commit intomainfrom
Conversation
Tests: - IFD chain loop / cycle detection in parse_all_ifds - RATIONAL/SRATIONAL with denominator=0 returning 0.0 - RATIONAL with count overflowing the buffer - Truncated IFD entry buffer - BigTIFF malformations (offset_size != 8, truncated header) - Classic TIFF first-IFD offset past buffer - Descending-y (south-up) write/read round-trip - Non-georeferenced TIFF read produces integer pixel coords Code: - _extract_transform now returns (transform, has_georef) so callers can tell "no GeoTIFF tags" apart from "tags present with default values". GeoInfo carries the new has_georef flag. - _geo_to_coords falls back to integer pixel coords (0..N-1) when has_georef is False, instead of producing y values like -0.5, -1.5, ... from the default unit transform.
2 tasks
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 #1482.
Summary
21 new tests in the geotiff module, plus one small reader fix.
Tests cover:
parse_all_ifdsalready had aseenset; this adds a test that builds a malicious buffer where IFD2 points back at IFD1, so the guard can't regress silently._read_valueedge cases: RATIONAL/SRATIONAL with denominator zero, RATIONAL count overflow, truncated IFD entry buffer.offset_size != 8, truncated 8-byte BigTIFF header.crsattr, instead of fractional coords from the default unit transform.Code change
_extract_transformnow returns(transform, has_georef).GeoInfocarries a newhas_georefflag._geo_to_coordsfalls back to integer pixel coords whenhas_georefis False. Existing georeferenced reads behave identically.Test plan
pytest xrspatial/geotiff/tests/test_header.py xrspatial/geotiff/tests/test_georef_edges.pytest_features.py::TestPaletteare unrelated and present onmain.