mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -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
|
// Read three digits at a time
|
||||||
while (count >= 3) {
|
while (count >= 3) {
|
||||||
// Each 10 bits encodes three digits
|
// Each 10 bits encodes three digits
|
||||||
|
if (bits.available() < 10) {
|
||||||
|
throw FormatException.getFormatInstance();
|
||||||
|
}
|
||||||
int threeDigitsBits = bits.readBits(10);
|
int threeDigitsBits = bits.readBits(10);
|
||||||
if (threeDigitsBits >= 1000) {
|
if (threeDigitsBits >= 1000) {
|
||||||
throw FormatException.getFormatInstance();
|
throw FormatException.getFormatInstance();
|
||||||
|
@ -286,6 +289,9 @@ final class DecodedBitStreamParser {
|
||||||
}
|
}
|
||||||
if (count == 2) {
|
if (count == 2) {
|
||||||
// Two digits left over to read, encoded in 7 bits
|
// Two digits left over to read, encoded in 7 bits
|
||||||
|
if (bits.available() < 7) {
|
||||||
|
throw FormatException.getFormatInstance();
|
||||||
|
}
|
||||||
int twoDigitsBits = bits.readBits(7);
|
int twoDigitsBits = bits.readBits(7);
|
||||||
if (twoDigitsBits >= 100) {
|
if (twoDigitsBits >= 100) {
|
||||||
throw FormatException.getFormatInstance();
|
throw FormatException.getFormatInstance();
|
||||||
|
@ -294,6 +300,9 @@ final class DecodedBitStreamParser {
|
||||||
result.append(toAlphaNumericChar(twoDigitsBits % 10));
|
result.append(toAlphaNumericChar(twoDigitsBits % 10));
|
||||||
} else if (count == 1) {
|
} else if (count == 1) {
|
||||||
// One digit left over to read
|
// One digit left over to read
|
||||||
|
if (bits.available() < 4) {
|
||||||
|
throw FormatException.getFormatInstance();
|
||||||
|
}
|
||||||
int digitBits = bits.readBits(4);
|
int digitBits = bits.readBits(4);
|
||||||
if (digitBits >= 10) {
|
if (digitBits >= 10) {
|
||||||
throw FormatException.getFormatInstance();
|
throw FormatException.getFormatInstance();
|
||||||
|
|
Loading…
Reference in a new issue