Files
rtl_433/tests
Andrew Berry 5e20bd2c40 Fix http server truncating large get_stats/get_protocols JSON
The /cmd getters serialized into fixed stack buffers (get_stats 20480,
get_meta 2048, get_protocols 102400). When a report exceeded its buffer
the output was silently corrupted into invalid JSON, not cleanly
truncated: the abuf string builder drops an oversized chunk but keeps
appending the smaller chunks that follow, so e.g. a get_stats reply with
~230 enabled decoders ended like `...,"name":,:8256}`. Clients then fail
to parse the response and the corresponding data never updates.

Make the serializer report truncation and add data_print_jsons_dup(),
which grows a heap buffer until the whole document fits, and use it for
the three JSON-payload getters:

- abuf gains an `overflow` flag, set by abuf_cat/abuf_printf and the
  hand-rolled string formatter whenever a write is dropped or truncated.
- data_print_jsons_dup() retries with a doubled buffer until no overflow
  (64 MiB sanity cap), so the report is never truncated.
- get_stats/get_meta/get_protocols use it and free the buffer after
  responding; out-of-memory yields an error reply instead of a partial one.

Tests:
- data-test asserts a large report serializes to a complete object via
  data_print_jsons_dup() while a fixed undersized buffer does not.
- the HTTP integration test now validates that get_protocols/get_stats/
  get_meta return parseable JSON, not just HTTP 200.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 13:43:12 +02:00
..
2020-09-18 19:45:27 +02:00
2026-02-25 13:04:28 +01:00