samtools / htslib

C library for high-throughput sequencing data formats
Other
804 stars 446 forks source link

Fix B aux tag length check in cram_encode_aux #1725

Closed daviesrob closed 9 months ago

daviesrob commented 9 months ago

B tags need eight bytes. Previously this only checked for at least seven, which could lead to a single byte out of bounds read. The impact of this is mostly limited by a later check on blen; however it was also possible that blen could overflow, allowing the check to incorrectly pass. A second commit expands blen so it can't overflow, and ensures it has an acceptable value before passing it to the encode function.