samtools / htsjdk

A Java API for high-throughput sequencing data (HTS) formats.
http://samtools.github.io/htsjdk/
283 stars 242 forks source link

Fix to ensure that SeekableStream#available() never returns a negative value #1255

Closed tomwhite closed 5 years ago

tomwhite commented 5 years ago

Description

For files that are larger than 2GB (e.g. an uncompressed FASTA) it is possible that length - position in SeekableStream#available() overflows an int, resulting in a negative value being returned.

This fixes the problem described here: https://github.com/broadinstitute/gatk/issues/5547

Checklist

tomwhite commented 5 years ago

@cmnbroad @lbergelson can you review please?

lbergelson commented 5 years ago

I really wish that java would throw exceptions on overflow...

lbergelson commented 5 years ago

I wonder if there are any static analysis tools that would have pointed this out as a probable error...