summaryrefslogtreecommitdiff
path: root/core/src/test/java
diff options
context:
space:
mode:
authorjmestwa-coder <jmestwa@gmail.com>2026-06-03 21:53:11 +0300
committerGitHub <noreply@github.com>2026-06-03 21:53:11 +0300
commit39e24ff4734e415d4a5995795c9e1017856b6d58 (patch)
tree330cb409cd732fabcb9cda4408b7e94aecab2a4e /core/src/test/java
parentddd4765ae4897b8b1bae32e6cd859bd6b6e681f6 (diff)
downloadzxing-39e24ff4734e415d4a5995795c9e1017856b6d58.tar.xz
guard base256 length read in datamatrix decodeBase256Segment (#2084)
Diffstat (limited to 'core/src/test/java')
-rw-r--r--core/src/test/java/com/google/zxing/datamatrix/decoder/DecodedBitStreamParserTestCase.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/src/test/java/com/google/zxing/datamatrix/decoder/DecodedBitStreamParserTestCase.java b/core/src/test/java/com/google/zxing/datamatrix/decoder/DecodedBitStreamParserTestCase.java
index a0bbc58d3..af44989d2 100644
--- a/core/src/test/java/com/google/zxing/datamatrix/decoder/DecodedBitStreamParserTestCase.java
+++ b/core/src/test/java/com/google/zxing/datamatrix/decoder/DecodedBitStreamParserTestCase.java
@@ -16,6 +16,7 @@
package com.google.zxing.datamatrix.decoder;
+import com.google.zxing.FormatException;
import org.junit.Assert;
import org.junit.Test;
@@ -42,6 +43,14 @@ public final class DecodedBitStreamParserTestCase extends Assert {
assertEquals("00019899", decodedString);
}
+ @Test(expected = FormatException.class)
+ public void testBase256TruncatedLongLength() throws Exception {
+ // 231 latches to Base 256. The next byte unrandomizes to 250 at codeword position 2,
+ // which signals a multi-byte length, but no further byte is present to read.
+ byte[] bytes = {(byte) 231, (byte) 38};
+ DecodedBitStreamParser.decode(bytes);
+ }
+
// TODO(bbrown): Add test cases for each encoding type
// TODO(bbrown): Add test cases for switching encoding types
} \ No newline at end of file