1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-05-10 08:04:02 +00:00

raster/vector: fix BARCODE_BIND_TOP trumping BARCODE_BOX

backend/tests/fuzz: update "fuzz.h" to take `option_3` min/max;
  update `INPUT_MODE_MASK` & `OUTPUT_OPTIONS_MASK`;
  set `height`, `border_width` & `output_options` from input
  (removing `Z_FUZZ_SET_OUTPUT_OPTIONS` conditional) and call
  `ZBarcode_Encode_and_Print()` instead of `ZBarcode_Encode()`;
  support standalone builds of "fuzz_data" & "fuzz_gs1" with
  `Z_FUZZ_MAIN_READ_ARGV_1` macro;
  update "fuzz_gs1" & "fuzz_gs1.dict" to better test caret/raw
  modes;
  gen_corpora: add `output_options`, `height` & `border_width` &
  find (3rd) from fuzz_data of BIND_TOP | BIND_BOX bug
This commit is contained in:
gitlost
2026-03-22 15:05:53 +00:00
parent f6174cba04
commit 56fca5b2a1
18 changed files with 494 additions and 307 deletions

View File

@@ -1,7 +1,7 @@
/* fuzz_data.c - fuzzer for libzint (DATA_MODE, all symbologies except GS1_128, DBAR_EXP/STK & composites) */
/*
libzint - the open source barcode library
Copyright (C) 2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2024-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -36,13 +36,24 @@ extern "C" {
#if 0
#define Z_FUZZ_DEBUG /* Set `symbol->debug` flag */
#define Z_FUZZ_SET_OUTPUT_OPTIONS /* Set `symbol->output_options` */
#endif
#include "fuzz.h"
#if Z_FUZZ_MAIN
/* For testing that a corpus file reproduces a bug:
cc -g -O0 -DZ_FUZZ_MAIN fuzz_data.c -o fuzz_data -lzint -fsanitize=address
./fuzz_data <corpus-file>
*/
#include <errno.h>
#include <limits.h>
Z_FUZZ_MAIN_READ_ARGV_1(idx, buf)
#else
int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) {
struct zint_symbol *symbol;
int idx;
unsigned char *buf; /* Dummy, used by "fuzz_gs1.c" */
#endif
(void)buf;
/* Ignore empty or very large input */
if (size < 1 || size > 10000) {
@@ -70,8 +81,9 @@ int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) {
if (!length) {
continue;
}
symbol->output_options |= BARCODE_MEMORY_FILE;
ret = ZBarcode_Encode(symbol, input, length);
ret = ZBarcode_Encode_and_Print(symbol, input, length, 0 /*rotate_angle*/);
assert(ret != ZINT_ERROR_ENCODING_PROBLEM);
}