#181 auspost fix, check input immediately; test for EANX double + fix

This commit is contained in:
gitlost
2020-03-25 15:40:13 +00:00
parent ee291e45d6
commit c245a11da2
4 changed files with 130 additions and 7 deletions

View File

@ -252,12 +252,51 @@ static void test_vector_same(void)
testFinish();
}
// #181 Christian Hartlage OSS-Fuzz
static void test_eanx_fuzz(void)
{
testStart("");
int ret;
struct item {
int symbology;
unsigned char* data;
int length;
int ret;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_EANX, "55++15", -1, ZINT_ERROR_INVALID_DATA },
};
int data_size = sizeof(data) / sizeof(struct item);
for (int i = 0; i < data_size; i++) {
struct zint_symbol* symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = data[i].symbology;
int length = data[i].length;
if (length == -1) {
length = strlen(data[i].data);
}
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);
}
testFinish();
}
int main()
{
test_upce_length();
test_upca_print();
test_isbn();
test_vector_same();
test_eanx_fuzz();
testReport();