From 776e9b6a06713922b23a78facf7f8c8075585e9b Mon Sep 17 00:00:00 2001 From: "smparkes@smparkes.net" Date: Tue, 28 Jun 2011 16:06:13 +0000 Subject: [PATCH] C++ changes to parallel r1837 git-svn-id: https://zxing.googlecode.com/svn/trunk@1840 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp b/cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp index 1903a266b..35cad2bfc 100644 --- a/cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp +++ b/cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp @@ -144,6 +144,9 @@ namespace zxing { // Read three digits at a time while (count >= 3) { // Each 10 bits encodes three digits + if (bits->available() < 10) { + throw ReaderException("format exception"); + } int threeDigitsBits = bits->readBits(10); if (threeDigitsBits >= 1000) { ostringstream s; @@ -157,6 +160,9 @@ namespace zxing { count -= 3; } if (count == 2) { + if (bits->available() < 7) { + throw ReaderException("format exception"); + } // Two digits left over to read, encoded in 7 bits int twoDigitsBits = bits->readBits(7); if (twoDigitsBits >= 100) { @@ -168,6 +174,9 @@ namespace zxing { bytes[i++] = ALPHANUMERIC_CHARS[twoDigitsBits / 10]; bytes[i++] = ALPHANUMERIC_CHARS[twoDigitsBits % 10]; } else if (count == 1) { + if (bits->available() < 4) { + throw ReaderException("format exception"); + } // One digit left over to read int digitBits = bits->readBits(4); if (digitBits >= 10) {