Skip to content

Commit

Permalink
jsonrpc: fix error when we abort batching due to timeout.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rustyrussell authored and cdecker committed Dec 6, 2022
1 parent 24d7aad commit 9751502
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lightningd/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,8 @@ static struct io_plan *read_json(struct io_conn *conn,
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);
}
}
Expand Down

0 comments on commit 9751502

Please sign in to comment.