UPCEAN: Check for multiple + characters in input

Fixes #181 reported by Christian Hartlage
This commit is contained in:
Robin Stuart 2020-02-15 21:28:40 +00:00
parent 0c5dc4d030
commit ee291e45d6

View File

@ -698,7 +698,7 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
unsigned char first_part[20] = {0}, second_part[20] = {0}, dest[1000] = {0};
unsigned char local_source[20] = {0};
unsigned int latch, reader, writer, with_addon;
int error_number, i;
int error_number, i, plus_count;
with_addon = FALSE;
@ -723,6 +723,18 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
return error_number;
}
}
/* Check for multiple '+' characters */
plus_count = 0;
for (i = 0; i < src_len; i++) {
if (source[i] == '+') {
plus_count++;
}
}
if (plus_count > 1) {
strcpy(symbol->errtxt, "293: Invalid add-on data");
return ZINT_ERROR_INVALID_DATA;
}
/* Add leading zeroes */
ustrcpy(local_source, (unsigned char *) "");