Skip to content

Commit 9a9e65c

Browse files
committed
Move test to separate test class & add CHANGES entry
1 parent a724a2f commit 9a9e65c

File tree

3 files changed

+55
-30
lines changed

3 files changed

+55
-30
lines changed

lucene/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ Improvements
239239

240240
* GITHUB#15479: Add NumericDocValueRangeQuery base class to add accessor methods for field, lower and upper values (Alan Woodward)
241241

242+
* GITHUB#15570: Disallow invalid offset 0 for LZ4 decompression (Marcono1234)
243+
242244
Optimizations
243245
---------------------
244246
* GITHUB#15140: Optimize TopScoreDocCollector with TernaryLongHeap for improved performance over Binary-LongHeap. (Ramakrishna Chilaka)

lucene/core/src/test/org/apache/lucene/util/compress/LZ4TestCase.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -384,34 +384,4 @@ public void testUseDictionary() throws IOException {
384384
// own
385385
assertTrue(out.size() < len);
386386
}
387-
388-
public void testDecompressOffset0() {
389-
byte[] input =
390-
new byte[] {
391-
// token
392-
0xE,
393-
// offset 0
394-
0,
395-
0,
396-
// last literal
397-
// token
398-
7 << 4,
399-
// literal
400-
0,
401-
0,
402-
0,
403-
0,
404-
0,
405-
0,
406-
0
407-
};
408-
409-
byte[] output = new byte[18];
410-
411-
var e =
412-
assertThrows(
413-
IOException.class,
414-
() -> LZ4.decompress(new ByteArrayDataInput(input), output.length, output, 0));
415-
assertEquals("offset 0 is invalid", e.getMessage());
416-
}
417387
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.lucene.util.compress;
18+
19+
import java.io.IOException;
20+
import org.apache.lucene.store.ByteArrayDataInput;
21+
import org.apache.lucene.tests.util.LuceneTestCase;
22+
23+
public class TestDecompressLZ4 extends LuceneTestCase {
24+
public void testDecompressOffset0() {
25+
byte[] input =
26+
new byte[] {
27+
// token
28+
0xE,
29+
// offset 0 (invalid)
30+
0,
31+
0,
32+
// last literal
33+
// token
34+
7 << 4,
35+
// literal
36+
0,
37+
0,
38+
0,
39+
0,
40+
0,
41+
0,
42+
0
43+
};
44+
45+
byte[] output = new byte[18];
46+
47+
var e =
48+
assertThrows(
49+
IOException.class,
50+
() -> LZ4.decompress(new ByteArrayDataInput(input), output.length, output, 0));
51+
assertEquals("offset 0 is invalid", e.getMessage());
52+
}
53+
}

0 commit comments

Comments
 (0)