Fixes for eci, binary div, upce, other

This commit is contained in:
gitlost
2019-09-01 20:23:15 +01:00
parent 89c2ee6f1d
commit d76cdd615b
11 changed files with 80 additions and 100 deletions

View File

@ -46,11 +46,9 @@ int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[]
int done;
if (eci == 26) {
int in_length = (int) *length;
/* Unicode mode, do not process - just copy data across */
for (in_posn = 0; in_posn < in_length; in_posn++) {
dest[in_posn] = source[in_posn];
}
memcpy(dest, source, *length);
dest[*length] = '\0';
return 0;
}
@ -107,42 +105,8 @@ int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[]
glyph += (source[in_posn + 2] & 0x3f);
}
if ((source[in_posn] >= 0xf0) && (source[in_posn] < 0xf7)) {
/* Four-byte character */
bytelen = 4;
glyph = (source[in_posn] & 0x07) << 18;
if (*length < (in_posn + 2)) {
return ZINT_ERROR_INVALID_DATA;
}
if (*length < (in_posn + 3)) {
return ZINT_ERROR_INVALID_DATA;
}
if (*length < (in_posn + 4)) {
return ZINT_ERROR_INVALID_DATA;
}
if (source[in_posn + 1] > 0xc0) {
return ZINT_ERROR_INVALID_DATA;
}
if (source[in_posn + 2] > 0xc0) {
return ZINT_ERROR_INVALID_DATA;
}
if (source[in_posn + 3] > 0xc0) {
return ZINT_ERROR_INVALID_DATA;
}
glyph += (source[in_posn + 1] & 0x3f) << 12;
glyph += (source[in_posn + 2] & 0x3f) << 6;
glyph += (source[in_posn + 3] & 0x3f);
}
if (source[in_posn] >= 0xf7) {
/* More than 4 bytes not supported */
if (source[in_posn] >= 0xf0 || glyph > 0x2122) {
/* Not in any ISO 8859 or Windows page */
return ZINT_ERROR_INVALID_DATA;
}
@ -269,6 +233,9 @@ int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[]
default:
break;
}
if (done) {
break;
}
}
if (!(done)) {