From 4a87abaa36a0bc1db5e99cca56377ae8a5b95242 Mon Sep 17 00:00:00 2001 From: Jan Olaf Krems Date: Fri, 30 Sep 2022 06:59:46 -0700 Subject: [PATCH] #105: test: fix out-of-bounds access Found with `-fsanitize=bounds`. Resolves #105. --- test/test_base64.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test_base64.c b/test/test_base64.c index bec52d14..ee8d7068 100644 --- a/test/test_base64.c +++ b/test/test_base64.c @@ -198,6 +198,11 @@ test_streaming (int flags) while (base64_stream_decode(&state, &ref[inpos], (inpos + bs > reflen) ? reflen - inpos : bs, &enc[enclen], &partlen)) { enclen += partlen; inpos += bs; + + // Has the entire buffer been consumed? + if (inpos >= 400) { + break; + } } if (enclen != 256) { printf("FAIL: stream decoding gave incorrect size: "