-
Notifications
You must be signed in to change notification settings - Fork 152
GH-1217: Bounds check before alloc in var-width view vectors #1291
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
base: main
Are you sure you want to change the base?
Changes from all commits
4d35fac
01e3fef
4478189
ed70a51
7c635f4
474c91c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2921,4 +2921,21 @@ public void testValidate() { | |
| assertTrue(e.getMessage().contains("Not enough capacity for data buffer")); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testValidateInvalidOffsets() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I just tested it: length ends up 64 (unchanged), prefix=4 (collateral overlap), bufferIndex=0, dataOffset=0 (not the intended 1024). The test passes, but I believe because dataLength=64 exceeds the tiny data buffer's capacity, not because of an out-of-range dataOffset like the test name implies. I suggest to use |
||
| try (final ViewVarCharVector vector = new ViewVarCharVector("v", allocator)) { | ||
| vector.allocateNew(16, 1); | ||
| vector.allocateOrGetLastDataBuffer(8); | ||
| var offsets = vector.getDataBuffer(); | ||
| offsets.setInt(0, Integer.MAX_VALUE); | ||
| offsets.setInt(4, 0); | ||
| offsets.setInt(8, 0); | ||
| offsets.setInt(12, 1024); | ||
| vector.setValueCount(1); | ||
| vector.setIndexDefined(0); | ||
| var e = assertThrows(IndexOutOfBoundsException.class, vector::validateFull); | ||
| assertTrue(e.getMessage().contains("index: 1024")); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.