Repository navigation
BUG: Report an error when an ANG header number cannot be parsed - #82
Closed
imikejackson wants to merge 1 commit into
Closed
imikejackson wants to merge 1 commit into
imikejackson wants to merge 1 commit into
Conversation
- AngHeaderEntry::parseValue() ignored a failed stream read. A header such as "XSTEP: 1e999" (overflow), "YSTEP: abc" or "NROWS: 99999999999" was accepted with FLT_MAX, 0 or INT_MAX. readHeaderOnly() returned success, so callers used the bad value (for example as geometry spacing), and readFile() then failed with an unrelated error or threw std::bad_alloc. - A numeric header entry now records a failed or non-finite parse (EbsdHeaderEntry::hasParseError(), default false). AngReader reports it as error -115 with a message that names the file, the header key and the raw text. readHeaderOnly() now clears the previous error and returns the error code when the header has one. - Valid headers are read exactly as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 13, 2026
Collaborator
Author
|
Closed in favor of #86, which merges this branch (with its history) together with the other open EbsdLib fixes for the next release, so simplnx can build against one EbsdLib branch. The branch is kept. 🤖 Generated with Claude Code |
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
AngHeaderEntry::parseValue()read a numeric header value withss >> m_valueand did not check the stream. A value that is not a number or is out of range was accepted with no error:develop# XSTEP: 1e999# YSTEP: abc# NROWS: 99999999999# NCOLS_ODD: tworeadHeaderOnly()returned success for all of these, so a caller such as the simplnx ReadAngDataFilter preflight used the value as Image Geometry spacing or dimensions.readFile()then failed later with an unrelated error (-110 zero step, -101105 grid mismatch), or threwstd::bad_allocfor the NROWS overflow.floatentries also a non-finite value. The new virtualEbsdHeaderEntry::hasParseError()returns false by default, so text entries and the CTF entries do not change (additive API).AngReader::parseHeaderLine()reports the first such value as an error.readFile()already stops after the header when the error code is negative.readHeaderOnly()now clears the previous error at the start, asreadFile()does, and returns the error code when the header has one. For a valid header it still returns 1.Ang file '<path>' has a header value that is not a valid number: XSTEP = '1e999'. Correct the value in the header.Not changed:
# XSTEP:) never reachesparseValue(); the entry keeps its default and the existing checks reject it (-110 for a step, -200 for NROWS).12abc) is still read as the number. Rejecting it was not needed for this defect.readFile()ondevelopalready rejects a negative step for a square grid (-101104 from the raster-order check, also for a 1 x 1 grid), and hex grids are rejected with -400, so no change was made. Non-positive NCOLS is handled by BUG: Use one column count for a square-grid ANG file #73; NROWS < 1 is already -200.Test Plan
EbsdLib::ebsdlib::AngImportTest-TestUnparsableHeaderValue(inAngImportTest.cpp) fails ondevelopand passes with this change. It writes small .ang files withXSTEP: 1e999,YSTEP: abc,NROWS: 99999999999andNCOLS_ODD: two, checksreadHeaderOnly()andreadFile()both return -115 with the file, key and raw text in the message, and checks that a valid header still reads. Ondevelop:readHeaderOnly()returned 1 for every case;readFile()returned -101105, -110 or threwstd::bad_alloc.ctestsuite passes, 430/430.Overlap
#73 (
fix/ang_square_grid_columns) also changesAngReader.cpp(the square-grid column check inreadFile(), codes -120 and -130). The hunks do not overlap; either merge order works.Related Issue
Related to BlueQuartzSoftware/simplnx#1877 (item
ReadAngDataFilter.cpp:119, XSTEP/YSTEP reach Image Geometry spacing unchecked) and BlueQuartzSoftware/simplnx#1908 (item L88).🤖 Generated with Claude Code