WAVE: Fix parse error in Associated Data List #309
Merged
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.
In JHOVE 1.18.1, validating a WAVE file that contains an Associated Data List chunk results in the status "Not well-formed" with error message "Unexpected end of file".
Consider this minimal example (binary version is attached) which constitutes a WAVE file without any audio data (empty Data chunk) but with an Associated Data List:
The Associated Data List chunk (the chunk with ID "list") in this example has size 0x14 (little endian), meaning it holds 20 bytes of data. These 20 bytes include the list's type ID "adtl" and the nested sub-chunk (the chunk with ID "labl"): 4 bytes for the "adtl" string plus 16 bytes for the "labl" chunk.
When reading an Associated Data List's sub-chunks JHOVE eats bytes according to the value of the
bytesLeft
variable by calling thegetNextChunkHeader()
method. ThebytesLeft
variable is initialized with the Associated Data List's size. So in this example JHOVE tries to read 20 bytes worth of sub-chunks. But alas, JHOVE ignores the fact that the "adtl" type ID has a size of its own! It should not read 20 bytes of sub-chunks, but only 16 bytes, allowing for the 4 bytes that are consumed by the type ID. So JHOVE should subtract 4 bytes from thebytesLeft
variable before it starts reading sub-chunks, just like it does in the ListInfoChunk class.This pull request adjusts this behaviour.
adtl.zip