mirror of
https://github.com/merbanan/rtl_433.git
synced 2026-06-11 02:25:24 -04:00
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>