mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
#181 auspost fix, check input immediately; test for EANX double + fix
This commit is contained in:
@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user