Repository navigation
Validate update control ranges in ApplyChanges - #29
Merged
Merged
Conversation
An FSPC, FFPC, VRPC or SGCC index or count outside the base record's array made ApplyChanges throw ArgumentOutOfRangeException from System.Collections.Immutable, with nothing to identify the record or field. The splice helpers now check the range (S-57 Part 3, 8.4.3) and throw InvalidDataException naming the control field and the record's RCNM/RCID. Throwing rather than logging and skipping: a skipped splice would return a record with silently wrong geometry, and ApplyChanges has no logger. Arrays the update leaves untouched (no update data, or a delete on an empty array) are still skipped without a check, because SGCC controls both SG2D and SG3D.
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.
Summary
S57Document.ApplyChangespassed the FSPC, FFPC, VRPC and SGCC index and count straight toImmutableArray.RemoveRangeandInsertRange. An update whose range fell outside the base record's array (a malformed.00N, or one that doesn't match the base cell) threwArgumentOutOfRangeExceptionfrom System.Collections.Immutable, with nothing to identify the record or field. Found with a synthetic update generator: an SGCC modify longer than the base edge's coordinate list crashedApplyChanges.The splice helpers now check the range and throw
InvalidDataException, for example:Why throw rather than log and skip:
S57DocumentReaderlogs and continues because a field it can't parse is just lost data. A skipped splice would instead return a record with silently wrong geometry.ApplyChangesalso has no logger, so throwing is the smaller change. The behaviour is documented in an<exception>tag and a remarks paragraph onApplyChanges.Standards alignment
iso8211)s57-enc)chart-viewer)Standard section references cited in code or docs: S-57 Part 3, 8.4.3 (update control fields).
Tests
tests/dotnet test --configuration Releasepasses locallyNew tests in
S57DocumentApplyChangesTests.cs: out-of-range SGCC modify, FSPC delete, FFPC insert, VRPC index 0, plus two boundary cases that must still work (a modify covering the last entry, an insert that appends).On the unchecked box: the machine I ran on couldn't reach nuget.org, so package validation couldn't restore the 0.7.2 baseline. All 498 tests pass with
dotnet test --configuration Release -p:EnablePackageValidation=false. CI runs the full command.Documentation
src/<project>/README.mddocs/if user-facing behavior changeddocfx docfx.json --warningsAsErrorspasses, if docs changedNo new public API. The existing
ApplyChangesXML docs gain the exception and range rules. The README and guides don't coverApplyChangeserrors, so they're unchanged.Dependencies
Directory.Packages.props(not in the.csproj)gh-advisory-databasesecurity check run for any new dependencyBreaking changes
No binary change; only private helpers changed. Behavioural change: for an out-of-range update control,
ApplyChangesnow throwsInvalidDataExceptioninstead ofArgumentOutOfRangeException. EncDotNet.S100 code that catchesArgumentOutOfRangeExceptionaroundApplyChanges(inEncDotNet.S100.Datasets.S57) would need to catchInvalidDataExceptioninstead. Valid updates behave as before.