fuzz-tests: Add a roundtrip check for `bigsize_put()`
What changed, and why it matters
This commit only adds an extra self-check to an existing software test. It makes the test verify that encoding a number and then decoding it gives back the same number. There is no change to the actual program code that users run, and nothing in the commit suggests a security problem was found or fixed.
No action required. This is a benign test-only improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies tests/fuzz/fuzz-bigsize.c, a fuzzing harness. It renames a loop variable and adds a roundtrip assertion: after serializing a bigsize value with bigsize_put(), it deserializes the result with bigsize_get() and checks the decoded value equals the original. This is a test-hardening change, not a functional or security patch.
Changed components
tests/fuzz/fuzz-bigsize.cInspect captured patch +5 / −3
diff --git a/tests/fuzz/fuzz-bigsize.c b/tests/fuzz/fuzz-bigsize.c
index 43b6af46..fb0b8ab3 100644
--- a/tests/fuzz/fuzz-bigsize.c
+++ b/tests/fuzz/fuzz-bigsize.c
@@ -14,15 +14,17 @@ void run(const uint8_t *data, size_t size)
const uint8_t **wire_chunks, *wire_ptr;
size_t wire_max;
- for (size_t max = 1; max <= BIGSIZE_MAX_LEN; max++) {
- wire_chunks = get_chunks(NULL, data, size, max);
+ for (size_t chunk_size = 1; chunk_size <= BIGSIZE_MAX_LEN; chunk_size++) {
+ wire_chunks = get_chunks(NULL, data, size, chunk_size);
for (size_t i = 0; i < tal_count(wire_chunks); i++) {
wire_max = tal_count(wire_chunks[i]);
wire_ptr = wire_chunks[i];
- bigsize_t bs = fromwire_bigsize(&wire_ptr, &wire_max);
+ bigsize_t bs = fromwire_bigsize(&wire_ptr, &wire_max), bs_decoded;
assert(bigsize_put(buff, bs) > 0);
assert(bigsize_len(bs));
+ assert(bigsize_get(buff, sizeof(buff), &bs_decoded) == bigsize_len(bs));
+ assert(bs_decoded == bs);
wire_buff = tal_arr(NULL, uint8_t, 8);
towire_bigsize(&wire_buff, bs);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.