Prevent buffer overrun in Code One

Fixes #184 reported by Milton Neal
This commit is contained in:
Robin Stuart 2020-03-29 14:23:31 +01:00
parent 52214c5a1c
commit 0244904c1f

View File

@ -441,11 +441,13 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
if (j == 13) {
latch = 0;
if ((length - sp) >= 14) {
for (i = sp + 13; i < length; i++) {
if (!((source[i] >= '0') && (source[i] <= '9'))) {
latch = 1;
}
}
}
if (!(latch)) {
next_mode = C1_DECIMAL;
@ -490,11 +492,13 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
if (j == 7) {
latch = 0;
if ((length - sp) >= 8) {
for (i = sp + 7; i < length; i++) {
if (!((source[sp + i] >= '0') && (source[sp + i] <= '9'))) {
latch = 1;
}
}
}
if (!(latch)) {
target[tp] = 236; /* FNC1 and change to Decimal */