Issue 1736 reject UPC/EAN less than 8 chars

git-svn-id: https://zxing.googlecode.com/svn/trunk@2871 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen@gmail.com 2013-08-19 10:24:59 +00:00
parent 5fd33bb9d2
commit a582958cc3
2 changed files with 11 additions and 0 deletions

View file

@ -176,6 +176,10 @@ public abstract class UPCEANReader extends OneDReader {
}
String resultString = result.toString();
// UPC/EAN should never be less than 8 chars anyway
if (resultString.length() < 8) {
throw FormatException.getFormatInstance();
}
if (!checkChecksum(resultString)) {
throw ChecksumException.getChecksumInstance();
}

View file

@ -23,6 +23,7 @@
#include <zxing/oned/OneDResultPoint.h>
#include <zxing/ReaderException.h>
#include <zxing/NotFoundException.h>
#include <zxing/FormatException.h>
#include <zxing/ChecksumException.h>
using std::vector;
@ -31,6 +32,7 @@ using std::string;
using zxing::Ref;
using zxing::Result;
using zxing::NotFoundException;
using zxing::FormatException;
using zxing::ChecksumException;
using zxing::oned::UPCEANReader;
@ -138,6 +140,11 @@ Ref<Result> UPCEANReader::decodeRow(int rowNumber,
throw NotFoundException();
}
// UPC/EAN should never be less than 8 chars anyway
if (result.length() < 8) {
throw FormatException();
}
Ref<String> resultString (new String(result));
if (!checkChecksum(resultString)) {
throw ChecksumException();