Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.

Commit f64bac4

Browse files
committed
Add test for a premature magicnb after a skippable frame
1 parent fa30b17 commit f64bac4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/test/net/jpountz/lz4/LZ4FrameIOStreamTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ public void testSkippableOnly() throws IOException {
294294
try (InputStream is = new LZ4FrameInputStream(new FileInputStream(lz4File))) {
295295
Assert.assertEquals(-1, is.read());
296296
}
297+
// Extra one byte at the tail
298+
try (InputStream is = new LZ4FrameInputStream(new SequenceInputStream(new FileInputStream(lz4File), new ByteArrayInputStream(new byte[1])))) {
299+
is.read();
300+
Assert.assertFalse(true);
301+
} catch (IOException ex) {
302+
// OK
303+
} catch (Exception ex) {
304+
Assert.assertFalse(true);
305+
}
297306
} finally {
298307
lz4File.delete();
299308
}
@@ -542,6 +551,7 @@ public void testPrematureMagicNb() throws IOException {
542551
copy(is, os);
543552
}
544553
}
554+
// Extra one byte at the tail
545555
try (InputStream is = new LZ4FrameInputStream(new SequenceInputStream(new FileInputStream(lz4File), new ByteArrayInputStream(new byte[1])))) {
546556
validateStreamEquals(is, tmpFile);
547557
is.read();

0 commit comments

Comments
 (0)