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

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

Merged
merged 1 commit into from
Jan 9, 2019

Conversation

tomwhite
Copy link
Contributor

@tomwhite tomwhite commented Jan 9, 2019

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: broadinstitute/gatk#5547

Checklist

  • Code compiles correctly
  • New tests covering changes and new functionality
  • All tests passing
  • Extended the README / documentation, if necessary
  • Is not backward compatible (breaks binary or source compatibility)

…e value.

For files that are larger than 2GB (e.g. an uncompressed FASTA) it is possible that
`length - position` overflows an int, resulting in a negative value being returned.
@tomwhite
Copy link
Contributor Author

tomwhite commented Jan 9, 2019

@cmnbroad @lbergelson can you review please?

@@ -107,8 +107,13 @@ public int available() throws IOException {
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is cursed.... @droazen

@lbergelson
Copy link
Member

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

Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomwhite Good catch. Thank you.

@lbergelson
Copy link
Member

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

@lbergelson lbergelson merged commit 68d9fdb into samtools:master Jan 9, 2019
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