From 9751502ff5382dc0bc77d46fcff29a13419ef4fd Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 6 Dec 2022 05:35:04 +1030 Subject: [PATCH] jsonrpc: fix error when we abort batching due to timeout. The read_json() call expects len_read to be the amount of *new* data read. If we call this back without resetting, it will parse this much random junk in the buffer. Fixes: #5766 Changelog-Fixed: Plugin: `autoclean` could misperform or get killed due to lightningd's invalid handling of JSON batching. --- lightningd/jsonrpc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index b311f50da..13a757ed2 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -1109,6 +1109,8 @@ again: start_time), time_from_msec(250))) { db_commit_transaction(jcon->ld->wallet->db); + /* Call us back, as if we read nothing new */ + jcon->len_read = 0; return io_always(conn, read_json, jcon); } }