mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Avoid AIOOBE for corrupt codes
git-svn-id: https://zxing.googlecode.com/svn/trunk@1837 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
ebf48833f0
commit
10065f8c1c
|
@ -275,6 +275,9 @@ final class DecodedBitStreamParser {
|
|||
// Read three digits at a time
|
||||
while (count >= 3) {
|
||||
// Each 10 bits encodes three digits
|
||||
if (bits.available() < 10) {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
int threeDigitsBits = bits.readBits(10);
|
||||
if (threeDigitsBits >= 1000) {
|
||||
throw FormatException.getFormatInstance();
|
||||
|
@ -286,6 +289,9 @@ final class DecodedBitStreamParser {
|
|||
}
|
||||
if (count == 2) {
|
||||
// Two digits left over to read, encoded in 7 bits
|
||||
if (bits.available() < 7) {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
int twoDigitsBits = bits.readBits(7);
|
||||
if (twoDigitsBits >= 100) {
|
||||
throw FormatException.getFormatInstance();
|
||||
|
@ -294,6 +300,9 @@ final class DecodedBitStreamParser {
|
|||
result.append(toAlphaNumericChar(twoDigitsBits % 10));
|
||||
} else if (count == 1) {
|
||||
// One digit left over to read
|
||||
if (bits.available() < 4) {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
int digitBits = bits.readBits(4);
|
||||
if (digitBits >= 10) {
|
||||
throw FormatException.getFormatInstance();
|
||||
|
|
Loading…
Reference in a new issue