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

commented Oct 3, 2019

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

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 3, 2019

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) == '=') {

This comment has been minimized.

Copy link
@tpoterba

tpoterba Oct 3, 2019

Collaborator

should be !(endField(pos) I think?

This comment has been minimized.

Copy link
@chrisvittal

chrisvittal Oct 3, 2019

Author Collaborator

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.

This comment has been minimized.

Copy link
@tpoterba

tpoterba Oct 3, 2019

Collaborator

OK, fair.

@chrisvittal chrisvittal dismissed tpoterba’s stale review Oct 3, 2019

Pushing back. Think the change is fine as is.

@danking danking merged commit dcf1180 into hail-is:master Oct 3, 2019
1 check passed
1 check passed
ci-test success
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.