Catch arrays of BCF_BT_NULL in bcf_record_check() #1486
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.
Adds a check for INFO/FORMAT values with type 0 ("A MISSING value without an explicit type provided") and number of elements > 0.
Normally type = 0 and number = 0 is used for a completely missing INFO/FORMAT value. In theory you could use number > 0 to make an array of missing values (at least the specification doesn't explicitly disallow it), however trying to do so results in bcf_fmt_array() reporting "Unexpected type 0" and calling exit(1). HTSJDK also appears to reject this encoding, and nothing appears to write it, so it seems reasonable to say that it's not valid.
The check for this encoding is added to bcf_record_check() so it's caught well before the data gets near bcf_fmt_array().
It also avoids problems with bcf_type_shift[], which cannot report the correct size of type = 0 encodings (it would need to multiply by 0, which isn't stricty possible with a shift).
Credit to OSS-Fuzz
Fixes oss-fuzz 49091