Stop crashing with large DotCode symbols

This commit is contained in:
Robin Stuart 2016-08-17 17:22:31 +01:00
parent 9d1c20201d
commit 3b366bbbd2

View File

@ -1083,6 +1083,11 @@ int dotcode(struct zint_symbol *symbol, unsigned char source[], int length) {
}
}
if ((height > 177) || (width > 177)) {
strcpy(symbol->errtxt, "Specified symbol size is too large");
return ZINT_ERROR_INVALID_OPTION;
}
n_dots = (height * width) / 2;
#ifndef _MSC_VER
@ -1107,6 +1112,13 @@ int dotcode(struct zint_symbol *symbol, unsigned char source[], int length) {
data_length++;
}
if (data_length > 450) {
// Larger data sets than this cause rsencode() to throw SIGSEGV
// This should probably be fixed by somebody who understands what rsencode() does...
strcpy(symbol->errtxt, "Input too long");
return ZINT_ERROR_TOO_LONG;
}
ecc_length = 3 + (data_length / 2);
/* Evaluate data mask options */