Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch arrays of BCF_BT_NULL in bcf_record_check() #1486

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

daviesrob
Copy link
Member

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

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
@whitwham whitwham merged commit ad80f8e into samtools:develop Aug 2, 2022
@daviesrob daviesrob deleted the missing_arrays branch August 5, 2022 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants