mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Stop crashing with large DotCode symbols
This commit is contained in:
parent
9d1c20201d
commit
3b366bbbd2
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user