asmaloney / asmaloney/libE57Format
Prototypes failing range check when writing
- Dominant language
- C++
- Stars
- 191
- Forks
- 82
- Avg merge
- 7h 21m
- Merged PRs (30d)
- 1
Description
A similar issue to #246 but different.
In file src/WriterImpl.cpp in method NewData3D we are creating prototypes, e.g.
` proto.set( "colorGreen", IntegerNode( imf_, 0, (int64_t)data3DHeader.colorLimits.colorGreenMinimum,
(int64_t)data3DHeader.colorLimits.colorGreenMaximum ) );`
The problem is that the minimum bounds has to be 0 or this code will fail because the default value being passed in for this prototype is 0. This makes the minimum bounds property effectively an unusable property for many data fields as it always has to be 0. When the minimum bounds is greater than 0 the software will crash with an E57_ERROR_VALUE_OUT_OF_BOUNDS exception.
As stated in #246 for prototypes (E57 Standard 8.3.9.3 (1)):
> (1) The prototype child element specifies the structure of the data that will be stored in the CompressedVector, as well as the possible range of values that the data may take. The prototype shall be any E57 element type (with potential sub-children) except Blob and CompressedVector. The values of the prototype elements and sub-elements are ignored, and need not be specified.
And in the header of the IntegerNode class:
```
Warning: it is an error to give an @a value outside the @a minimum / @a
maximum bounds, even if the IntegerNode is destined to be used in a
CompressedVectorNode prototype (where the @a value will be ignored). If the
IntegerNode is to be used in a prototype, it is recommended to specify a @a
value = 0 if 0 is within bounds, or a @a value = @a minimum if 0 is not within
bounds
```
Contributor guide
Research direction
Review src/WriterImpl.cpp, especially NewData3D and the IntegerNode prototype construction shown in the issue. Reproduce the out-of-bounds failure with a prototype whose minimum bound is above zero, then verify that prototype creation succeeds while retaining the declared bounds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100