From d42eb1384195e7ad625a4da088e15ab18f0a0194 Mon Sep 17 00:00:00 2001 From: gitlost Date: Thu, 4 Jan 2024 22:43:41 +0000 Subject: [PATCH] AZTEC: change max byte count from `assert()` to if as overlong data can trigger it (fuzz_data (1st)) --- backend/aztec.c | 4 +- backend/tests/fuzz/fuzz_data_seed_corpus.zip | Bin 10257 -> 10538 bytes backend/tests/fuzz/fuzz_gs1_seed_corpus.zip | Bin 969 -> 969 bytes backend/tests/fuzz/gen_corpora.c | 162 ++++++++++++++++--- backend/tests/test_aztec.c | 114 +++++++++++++ 5 files changed, 255 insertions(+), 25 deletions(-) diff --git a/backend/aztec.c b/backend/aztec.c index ca9b7571..4d90ad0d 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -576,7 +576,9 @@ static int aztec_text_process(const unsigned char source[], int src_len, int bp, int big_batch = 0; for (count = 0; ((i + count) < reduced_length) && (reduced_encode_mode[i + count] == 'B'); count++); - assert(count <= 2047 + 2078); /* Can't be more than 19968 / 8 = 2496 */ + if (count > 2047 + 2078) { /* Can't be more than 19968 / 8 = 2496 */ + return 0; + } if (count > 2047) { /* Max 11-bit number */ big_batch = count > 2078 ? 2078 : count; diff --git a/backend/tests/fuzz/fuzz_data_seed_corpus.zip b/backend/tests/fuzz/fuzz_data_seed_corpus.zip index dab063d12e1ed85468ad7143b7a0879f8ae45554..9547a085ba8be679a0ebaf1b6b6a8bad9f48aa3a 100644 GIT binary patch delta 3262 zcmZ`+4NOy46uxbN@>9xR|A1Rs1gRhoUSBJ;VFoL(NerVX7&bF;nJAfV62OIQVTxoX z>Zan$!i;9HY%yZ8WfNxHVuB7$aE=6wQ#UsqnZ~)uwrsj=BnvzDzVhC?ZF%I9oRjan z=iGD7{chSHJiX2kT&s&QA%x;l-Dtm|K;Iz@w8HB5b6Rk;DUNq5iQ|Us5Otbr@QAe< z#r2xTM_iw(Tt8}xh$}&>pvtr>iEEd(pfD7zbys&1(!~6tLx}!+Y4cDVLh97SOWLA^ z+{7nZ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