From 03b4f4778e8c9119fed30b9ad098851dfd9145a2 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 11 Jun 2025 06:34:12 +0930 Subject: [PATCH] lightningd: fix log crash on weird escape lines from plugin. Apparently clboss gives us \u UTF codes. We don't support that (use UTF-8 directly) ``` 126 ../sysdeps/x86_64/multiarch/strlen-vec.S: No such file or directory. (gdb) bt label=label@entry=0x63e2f9604db9 "char *[]") at ccan/ccan/tal/str/str.c:137 complete=complete@entry=0x7ffe9090b0f6, destroyed=destroyed@entry=0x7ffe9090b0f7) at lightningd/plugin.c:773 ``` Reported-by: Ken Sedgwick Fixes: #8338 Changelog-None: broken in this release Signed-off-by: Rusty Russell --- lightningd/plugin.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lightningd/plugin.c b/lightningd/plugin.c index e8fb7f4f4..2032640d2 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -522,6 +522,10 @@ static const char *plugin_log_handle(struct plugin *plugin, const char *log_msg = json_escape_unescape(tmpctx, esc); char **lines; + /* Weird \ escapes aren't handled by json_escape_unescape. This is for you, clboss! */ + if (!log_msg) + goto print_raw; + lines = tal_strsplit(tmpctx, log_msg, "\n", STR_EMPTY_OK); for (size_t i = 0; lines[i]; i++) { @@ -529,6 +533,7 @@ static const char *plugin_log_handle(struct plugin *plugin, log_(plugin->log, level, NULL, call_notifier, "%s", lines[i]); } } else { + print_raw: log_(plugin->log, level, NULL, call_notifier, "%.*s", msgtok->end - msgtok->start, plugin->buffer + msgtok->start);