Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.8, 4.9
-
None
-
New
Description
After implementing LUCENE-5681, I noticed, that some directory implementations (like NIOFSDirectory) do not do bounds checks on slice creation. We should do this to early detect bugs, if file formats break because of index corrumption.
This test in BaseDirectoryTestCase does not pass for all directory impls:
public void testSliceOutOfBounds() throws Exception { Directory dir = getDirectory(createTempDir("testSliceOutOfBounds")); IndexOutput o = dir.createOutput("out", newIOContext(random())); final int len = random().nextInt(2040) + 8; byte[] b = new byte[len]; o.writeBytes(b, 0, len); o.close(); IndexInput i = dir.openInput("out", newIOContext(random())); try { i.slice("slice1", 0, len + 1); fail("Did not get IllegalArgumentException"); } catch (IllegalArgumentException iae) { // pass } try { i.slice("slice2", -1, len); fail("Did not get IllegalArgumentException"); } catch (IllegalArgumentException iae) { // pass } IndexInput slice = i.slice("slice3", 4, len / 2); try { slice.slice("slice3sub", 1, len / 2); fail("Did not get IllegalArgumentException"); } catch (IllegalArgumentException iae) { // pass } i.close(); dir.close(); }
Attachments
Attachments
Issue Links
- relates to
-
LUCENE-5681 Fix RAMDirectory's IndexInput to not double-buffer on slice()
- Resolved