CCAN: update to get json_escape_dup helper.
What changed, and why it matters
This commit imports a new helper function, json_escape_dup, from the CCAN library into Core Lightning. It simply adds a way to duplicate (copy) an already-escaped JSON string object. There is no visible bug fix, behavior change, or security patch in the diff itself.
No security action required. Treat as routine library/vendor update. If this commit is part of a larger change, review the follow-up commits that actually use json_escape_dup to ensure the helper is used safely.
Security signals we found
No security-relevant code change: pure helper addition
No memory-safety bug fixed in the diff
No input validation, parsing, or cryptographic logic changed
No vendor disclosure of security relevance present
Evidence from the diff
The patch updates the vendored CCAN copy to version init-2612-ge242779f and adds json_escape_dup() to ccan/ccan/json_escape. The new function duplicates a struct json_escape, either by reparenting the TAKES argument under a new tal context or by re-escaping the underlying string. It also adds two unit tests verifying that the duplicate equals the original. No existing callers are modified and no vulnerability is addressed in this commit.
Changed components
ccan/ccan/json_escape/json_escape.cccan/ccan/json_escape/json_escape.hccan/ccan/json_escape/test/run.cInspect captured patch +15 / −2
diff --git a/ccan/README b/ccan/README
index 047cf78a..6dd49e64 100644
--- a/ccan/README
+++ b/ccan/README
@@ -1,3 +1,3 @@
CCAN imported from http://ccodearchive.net.
-CCAN version: init-2611-g050dc66d
+CCAN version: init-2612-ge242779f
diff --git a/ccan/ccan/json_escape/json_escape.c b/ccan/ccan/json_escape/json_escape.c
index 4bbb0032..6344bd8a 100644
--- a/ccan/ccan/json_escape/json_escape.c
+++ b/ccan/ccan/json_escape/json_escape.c
@@ -20,6 +20,14 @@ bool json_escape_eq(const struct json_escape *a, const struct json_escape *b)
return streq(a->s, b->s);
}
+struct json_escape *json_escape_dup(const tal_t *ctx, const struct json_escape *esc TAKES)
+{
+ if (taken(esc))
+ return (struct json_escape *)tal_steal(ctx, esc);
+
+ return json_escape_string_(ctx, esc->s, strlen(esc->s));
+}
+
bool json_escape_needed(const char *str, size_t len)
{
size_t i;
diff --git a/ccan/ccan/json_escape/json_escape.h b/ccan/ccan/json_escape/json_escape.h
index 88d1eefc..6a53fd5d 100644
--- a/ccan/ccan/json_escape/json_escape.h
+++ b/ccan/ccan/json_escape/json_escape.h
@@ -27,6 +27,9 @@ struct json_escape *json_escape_len(const tal_t *ctx,
struct json_escape *json_partial_escape(const tal_t *ctx,
const char *str TAKES);
+/* Copy a json_escape */
+struct json_escape *json_escape_dup(const tal_t *ctx, const struct json_escape *esc TAKES);
+
/* Do we need to escape this str? */
bool json_escape_needed(const char *str, size_t len);
diff --git a/ccan/ccan/json_escape/test/run.c b/ccan/ccan/json_escape/test/run.c
index 9d8b049c..d81200e9 100644
--- a/ccan/ccan/json_escape/test/run.c
+++ b/ccan/ccan/json_escape/test/run.c
@@ -9,7 +9,7 @@ int main(void)
struct json_escape *e;
/* This is how many tests you plan to run */
- plan_tests(6);
+ plan_tests(8);
e = json_escape(ctx, "Hello");
ok1(!strcmp(e->s, "Hello"));
@@ -25,6 +25,7 @@ int main(void)
ok1(!strcmp(json_escape_unescape(ctx, e),
"\\\b\f\n\r\t\""
"\\\\\\b\\f\\n\\r\\t\\\""));
+ ok1(json_escape_eq(e, json_escape_dup(ctx, e)));
/* This one doesn't escape the already-escaped chars */
e = json_partial_escape(ctx,
@@ -36,6 +37,7 @@ int main(void)
ok1(!strcmp(json_escape_unescape(ctx, e),
"\\\b\f\n\r\t\""
"\\\b\f\n\r\t\""));
+ ok1(json_escape_eq(e, json_escape_dup(ctx, e)));
tal_free(ctx);
Why this scored 12/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.