1
0
Fork 0
mirror of https://git.code.sf.net/p/zint/code synced 2025-06-02 07:59:50 -04:00

Consistently throw an error if data does not fit in specified size symbol

See ticket 
This commit is contained in:
Robin Stuart 2017-04-11 09:26:39 +01:00
parent ff6995070b
commit 5acbffff0d
5 changed files with 23 additions and 4 deletions
backend

View file

@ -1425,6 +1425,7 @@ int code_one(struct zint_symbol *symbol, unsigned char source[], int length) {
data_length = c1_encode(symbol, source, data, length);
if (data_length == 0) {
strcpy(symbol->errtxt, "Input data is too long");
return ZINT_ERROR_TOO_LONG;
}
@ -1437,6 +1438,11 @@ int code_one(struct zint_symbol *symbol, unsigned char source[], int length) {
if (symbol->option_2 > size) {
size = symbol->option_2;
}
if ((symbol-> option_2 != 0) && (symbol->option_2 < size)) {
strcpy(symbol->errtxt, "Input too long for selected symbol size");
return ZINT_ERROR_TOO_LONG;
}
for (i = data_length; i < c1_data_length[size - 1]; i++) {
data[i] = 129; /* Pad */