Add fuzz stuff ("backend/tests/fuzz"), including OSS-Fuzz

"Dockerfile" etc
PDF417: lessen some debug verbosity
gif: use "gif_" prefix; some code fiddling
This commit is contained in:
gitlost 2024-01-04 20:11:04 +00:00
parent 2a55ba0cef
commit 3cb724253b
19 changed files with 1651 additions and 109 deletions

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -1561,15 +1561,15 @@ static void test_fuzz(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
char *data;
int length;
int input_mode;
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { "(\207'", -1, DATA_MODE, 0 }, /* 0x28,0x87,0x27 Note: should but doesn't trigger sanitize error if no length check, for some reason; UPDATE: use up-to-date gcc (9)! */
/* 1*/ {
/* 0*/ { DATA_MODE, "(\207'", -1, 0 }, /* 0x28,0x87,0x27 Note: should but doesn't trigger sanitize error if no length check, for some reason; UPDATE: use up-to-date gcc (9)! */
/* 1*/ { DATA_MODE,
"\133\061\106\133\061\106\070\161\116\133\116\116\067\040\116\016\000\116\125\111\125\125\316\125\125\116\116\116\116\117\116\125"
"\111\125\103\316\125\125\116\116\116\116\117\000\000\116\136\116\116\001\116\316\076\116\116\057\136\116\116\134\000\000\116\116"
"\116\230\116\116\116\116\125\125\125\257\257\257\000\001\116\130\212\212\212\212\212\212\212\377\377\210\212\212\177\000\212\212"
@ -1584,12 +1584,12 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\071\071\071\071\071\072\071\071\277\071\071\077\071\071\071\071\071\071\071\071\154\071\071\071\071\071\071\071\071\071\071\071"
"\071\071\071\011\071\071\071\071\071\071\071\071\071\071\071\071\071\071\105\105\105\105\105\105\105\105\105\105\105\105\105\071"
"\071\071\071\071\071", /* Original OSS-Fuzz triggering data for index out of bounds (encoding of HT/FS/GS/RS when shifting to code set B) */
421, DATA_MODE, 0 },
/* 2*/ { "\233:", -1, DATA_MODE, 0 }, /* Original OSS-Fuzz triggering data for codeword_array buffer overflow, L777 */
/* 3*/ { "\241\034", -1, DATA_MODE, 0 }, /* As above L793 */
/* 4*/ { "\270\036", -1, DATA_MODE, 0 }, /* As above L799 */
/* 5*/ { "\237\032", -1, DATA_MODE, 0 }, /* As above L904 */
/* 6*/ { "\237", -1, DATA_MODE, 0 }, /* As above L1090 */
421, 0 },
/* 2*/ { DATA_MODE, "\233:", -1, 0 }, /* Original OSS-Fuzz triggering data for codeword_array buffer overflow, L777 */
/* 3*/ { DATA_MODE, "\241\034", -1, 0 }, /* As above L793 */
/* 4*/ { DATA_MODE, "\270\036", -1, 0 }, /* As above L799 */
/* 5*/ { DATA_MODE, "\237\032", -1, 0 }, /* As above L904 */
/* 6*/ { DATA_MODE, "\237", -1, 0 }, /* As above L1090 */
};
int data_size = ARRAY_SIZE(data);
int i, length, ret;