Merged
Conversation
If we fail to extend the buffer, we shouldn't extend ref_end. This avoids needing to check downstream everywhere we use ref_end to make sure it's not bigger than ref_end_alloc. Instead we'll just get short references and need to encode overhanging sequences against Ns. Credit to OSS_Fuzz Fixes oss-fuzz issue 499447432
Converting a file to CRAM with embed_ref=2 and SQ LN:0 triggers some
unusual code paths because we use a non-zero length field as an
indicator for the referencing having been populated. In this case we
convert sequence to Ns (albeit not overflowing buffers and in a secure
way).
However it's a wider issue. LN:-2 was permitted and it gets convered
to MAX_INT in bam. Plus "LN:" (no length) was accepted and treated as
zero. So instead of putting the fix in cram_io.c refs_from_header()
("if (h->hrecs->ref[i].len <= 0) ...") we disallow this globally for
all file formats.
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.
Note this isn't CVE worthy as the code it fixes appeared since the last release.