You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2014/09/17 00:22:34 UTC
[jira] [Updated] (LUCENE-5827) Make all Directory implementations
correctly fail with IllegalArgumentException if slices are out of bounds
[ https://issues.apache.org/jira/browse/LUCENE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael McCandless updated LUCENE-5827:
---------------------------------------
Fix Version/s: 4.9.1
> Make all Directory implementations correctly fail with IllegalArgumentException if slices are out of bounds
> -----------------------------------------------------------------------------------------------------------
>
> Key: LUCENE-5827
> URL: https://issues.apache.org/jira/browse/LUCENE-5827
> Project: Lucene - Core
> Issue Type: Bug
> Components: core/store
> Affects Versions: 4.8, 4.9
> Reporter: Uwe Schindler
> Assignee: Uwe Schindler
> Fix For: 4.10, 5.0, 4.9.1
>
> Attachments: LUCENE-5827.patch
>
>
> 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:
> {code:java}
> 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();
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org