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

[hail][bugfix]: fix out of bounds read in LoadVCF #7182

Merged
merged 1 commit into from
Oct 3, 2019

Conversation

chrisvittal
Copy link
Collaborator

When reading flag fields, we attempt to check if line(pos) == '='.
When a flag occurs at end of line, pos will be equal to line.length,
and thus caused an out of bounds read on the string.

Added the bounds check to prevent this.

When reading flag fields, we attempt to check if `line(pos) == '='`.
When a flag occurs at end of line, pos will be equal to line.length,
and thus caused an out of bounds read on the string.

Added the bounds check to prevent this.
@chrisvittal
Copy link
Collaborator Author

ref: https://hail.zulipchat.com/#narrow/stream/123010-Hail-0.2E2.20support/topic/Error.20importing.20dbsnp.20VCF/near/177209550

I have confirmed that the test I added fails with the same error laurent saw in the linked conversation, and passes with the change.

@@ -914,7 +914,7 @@ final class VCFLine(val line: String, arrayElementsRequired: Boolean) {
if (infoType.hasField(key)) {
rvb.setFieldIndex(infoType.fieldIdx(key))
if (infoFlagFieldNames.contains(key)) {
if (line(pos) == '=') {
if (pos != line.length && line(pos) == '=') {
Copy link
Contributor

Choose a reason for hiding this comment

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

should be !(endField(pos) I think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

endField and pos != line.length are about as clear in my mind, and the second won't check needlessly for the presence of a tab.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, fair.

@chrisvittal chrisvittal dismissed tpoterba’s stale review October 3, 2019 03:10

Pushing back. Think the change is fine as is.

@danking danking merged commit dcf1180 into hail-is:master Oct 3, 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.

3 participants