bookkeeper: fix printing of bad JSON results.
What changed, and why it matters
This commit fixes a logging bug in the bookkeeper plugin where error messages printed only the start of a JSON response instead of the intended snippet. The code used the wrong pointer offset, so log lines showed garbage like '{"jsonrpc":"2' rather than the relevant data. It is a cosmetic/log-quality fix with no direct security impact.
No security action required. Treat as a normal code-quality/logging fix. Reviewers may optionally verify that no other '%.*s' JSON-token prints in the codebase have the same offset bug.
Security signals we found
No security-relevant code path modified
Fixes diagnostic log formatting only
No input validation, memory allocation, or cryptographic changes
Evidence from the diff
In plugins/bkpr/bookkeeper.c, four calls to plugin_err/plugin_log used ‘%.*s’ with buf (the full JSON buffer start) and a length computed as result->end - result->start. Because buf was not offset by result->start, the format specifier printed the first N characters of the buffer instead of the JSON token’s actual text. The patch changes these to buf + result->start so the logged snippet corresponds to the token being reported. This affects error/debug logging only; no parsing, authorization, or cryptographic logic is changed.
Changed components
plugins/bkpr/bookkeeper.cgetblockheight_done error logginglistinvoices_done error logginglistsendpays_done debug loggingInspect captured patch +4 / −4
diff --git a/plugins/bkpr/bookkeeper.c b/plugins/bkpr/bookkeeper.c
index 7521b210..72cda38f 100644
--- a/plugins/bkpr/bookkeeper.c
+++ b/plugins/bkpr/bookkeeper.c
@@ -238,12 +238,12 @@ getblockheight_done(struct command *cmd,
if (!blockheight_tok)
plugin_err(cmd->plugin, "getblockheight: "
"getinfo gave no 'blockheight'? '%.*s'",
- result->end - result->start, buf);
+ result->end - result->start, buf + result->start);
if (!json_to_u32(buf, blockheight_tok, &blockheight))
plugin_err(cmd->plugin, "getblockheight: "
"getinfo gave non-unsigned-32-bit 'blockheight'? '%.*s'",
- result->end - result->start, buf);
+ result->end - result->start, buf + result->start);
/* Get the income events */
apys = compute_channel_apys(cmd, bkpr, cmd,
@@ -1013,7 +1013,7 @@ listinvoices_done(struct command *cmd,
"listinvoices:"
" description/bolt11/bolt12"
" not found (%.*s)",
- result->end - result->start, buf);
+ result->end - result->start, buf + result->start);
return rinfo_one_done(cmd, phinfo->rinfo);
}
@@ -1053,7 +1053,7 @@ listsendpays_done(struct command *cmd,
plugin_log(cmd->plugin, LOG_DBG,
"listpays: bolt11/bolt12 not found:"
"(%.*s)",
- result->end - result->start, buf);
+ result->end - result->start, buf + result->start);
return rinfo_one_done(cmd, phinfo->rinfo);
}
Why this scored 18/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.