common/bolt12: use a const char * for fail reason.
What changed, and why it matters
This commit is a code-quality refactor across many files. It changes the 'failure reason' string returned by BOLT11/BOLT12 decoding functions from a mutable 'char *' to a read-only 'const char *'. It also exposes a previously internal helper function and adds memory ownership fixes so callers don't accidentally use freed error strings. There is no direct evidence in the commit message or diff that this fixes an active security vulnerability, but it removes a class of potential memory-management mistakes and makes the API safer for future callers.
Treat as a routine refactor with minor defensive-security value. Review that all callers now treat the failure string as const and do not attempt to free or modify it. No urgent patching is indicated by the diff alone, but include it in normal update cycles.
Security signals we found
Memory ownership fix: tal_steal(ctx, *fail) added in three BOLT12 decode paths
API hardening: decode failure strings are now const, discouraging mutation/use-after-free
Previously internal helper string_to_data() made public as b12_string_to_data()
No mention of CVE, security bug, or researcher attribution in commit message
Evidence from the diff
The patch modifies common/bolt11.c/h, common/bolt12.c/h and 26 other files to switch the ‘fail’ out-parameter type from ‘char ’ to ‘const char ’ in bolt11_decode, bolt11_decode_nosig, offer_decode, invrequest_decode, invoice_decode, and invoice_decode_minimal. The internal static string_to_data() in bolt12.c is renamed to b12_string_to_data() and exported in bolt12.h. Three decode entry points now call tal_steal(ctx, *fail) when b12_string_to_data() fails, ensuring the caller owns the error message buffer. The rest of the changes are mechanical type updates at call sites, tests, fuzzers, and CLI tools. No functional logic changes to parsing, validation, or cryptography are visible.
Changed components
common/bolt11.ccommon/bolt11.hcommon/bolt12.ccommon/bolt12.hlightningd/invoice.clightningd/offer.clightningd/pay.clightningd/runes.cplugins/fetchinvoice.cplugins/offers.cplugins/pay.cplugins/renepay/main.cplugins/xpay/xpay.ctests/fuzz/*Inspect captured patch +97 / −80
diff --git a/common/bolt11.c b/common/bolt11.c
index 26263dd0..27e5bd24 100644
--- a/common/bolt11.c
+++ b/common/bolt11.c
@@ -111,11 +111,11 @@ static void *pull_all(const tal_t *ctx,
}
/* Frees bolt11, returns NULL. */
-static struct bolt11 *decode_fail(struct bolt11 *b11, char **fail,
+static struct bolt11 *decode_fail(struct bolt11 *b11, const char **fail,
const char *fmt, ...)
PRINTF_FMT(3,4);
-static struct bolt11 *decode_fail(struct bolt11 *b11, char **fail,
+static struct bolt11 *decode_fail(struct bolt11 *b11, const char **fail,
const char *fmt, ...)
{
va_list ap;
@@ -752,7 +752,7 @@ struct bolt11 *bolt11_decode_nosig(const tal_t *ctx, const char *str,
struct sha256 *hash,
const u5 **sig,
bool *have_n,
- char **fail)
+ const char **fail)
{
const char *hrp, *prefix;
char *amountstr;
@@ -981,7 +981,7 @@ struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
const struct feature_set *our_features,
const char *description,
const struct chainparams *must_be_chain,
- char **fail)
+ const char **fail)
{
const u5 *sigdata;
size_t data_len;
diff --git a/common/bolt11.h b/common/bolt11.h
index b75ad55e..9c533675 100644
--- a/common/bolt11.h
+++ b/common/bolt11.h
@@ -92,7 +92,7 @@ struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
const struct feature_set *our_features,
const char *description,
const struct chainparams *must_be_chain,
- char **fail);
+ const char **fail);
/* Extracts signature but does not check it. */
struct bolt11 *bolt11_decode_nosig(const tal_t *ctx, const char *str,
@@ -102,7 +102,7 @@ struct bolt11 *bolt11_decode_nosig(const tal_t *ctx, const char *str,
struct sha256 *hash,
const u5 **sig,
bool *have_n,
- char **fail);
+ const char **fail);
/* Initialize an empty bolt11 struct with optional amount */
struct bolt11 *new_bolt11(const tal_t *ctx,
diff --git a/common/bolt12.c b/common/bolt12.c
index 1f2ccf1b..3b80f057 100644
--- a/common/bolt12.c
+++ b/common/bolt12.c
@@ -109,12 +109,12 @@ static char *check_signature(const tal_t *ctx,
return NULL;
}
-static const u8 *string_to_data(const tal_t *ctx,
- const char *str,
- size_t str_len,
- const char *hrp_expected,
- size_t *dlen,
- char **fail)
+const u8 *b12_string_to_data(const tal_t *ctx,
+ const char *str,
+ size_t str_len,
+ const char *hrp_expected,
+ size_t *dlen,
+ const char **fail)
{
char *hrp;
u8 *data;
@@ -169,7 +169,7 @@ struct tlv_offer *offer_decode(const tal_t *ctx,
const char *b12, size_t b12len,
const struct feature_set *our_features,
const struct chainparams *must_be_chain,
- char **fail)
+ const char **fail)
{
struct tlv_offer *offer;
const u8 *data;
@@ -177,9 +177,11 @@ struct tlv_offer *offer_decode(const tal_t *ctx,
const struct tlv_field *badf;
const struct recurrence *recurr;
- data = string_to_data(tmpctx, b12, b12len, "lno", &dlen, fail);
- if (!data)
- return NULL;;
+ data = b12_string_to_data(tmpctx, b12, b12len, "lno", &dlen, fail);
+ if (!data) {
+ tal_steal(ctx, *fail);
+ return NULL;
+ }
offer = fromwire_tlv_offer(ctx, &data, &dlen);
if (!offer) {
@@ -325,16 +327,18 @@ struct tlv_invoice_request *invrequest_decode(const tal_t *ctx,
const char *b12, size_t b12len,
const struct feature_set *our_features,
const struct chainparams *must_be_chain,
- char **fail)
+ const char **fail)
{
struct tlv_invoice_request *invrequest;
const u8 *data;
size_t dlen;
const struct tlv_field *badf;
- data = string_to_data(tmpctx, b12, b12len, "lnr", &dlen, fail);
- if (!data)
+ data = b12_string_to_data(tmpctx, b12, b12len, "lnr", &dlen, fail);
+ if (!data) {
+ tal_steal(ctx, *fail);
return NULL;
+ }
invrequest = fromwire_tlv_invoice_request(ctx, &data, &dlen);
if (!invrequest) {
@@ -393,15 +397,17 @@ struct tlv_invoice *invoice_decode_minimal(const tal_t *ctx,
const char *b12, size_t b12len,
const struct feature_set *our_features,
const struct chainparams *must_be_chain,
- char **fail)
+ const char **fail)
{
struct tlv_invoice *invoice;
const u8 *data;
size_t dlen;
- data = string_to_data(tmpctx, b12, b12len, "lni", &dlen, fail);
- if (!data)
+ data = b12_string_to_data(tmpctx, b12, b12len, "lni", &dlen, fail);
+ if (!data) {
+ tal_steal(ctx, *fail);
return NULL;
+ }
invoice = fromwire_tlv_invoice(ctx, &data, &dlen);
if (!invoice) {
@@ -540,7 +546,7 @@ struct tlv_invoice *invoice_decode(const tal_t *ctx,
const char *b12, size_t b12len,
const struct feature_set *our_features,
const struct chainparams *must_be_chain,
- char **fail)
+ const char **fail)
{
struct tlv_invoice *invoice;
diff --git a/common/bolt12.h b/common/bolt12.h
index a836f52f..1f9b61f9 100644
--- a/common/bolt12.h
+++ b/common/bolt12.h
@@ -32,7 +32,7 @@ char *offer_encode(const tal_t *ctx, const struct tlv_offer *bolt12_tlv);
struct tlv_offer *offer_decode(const tal_t *ctx, const char *b12, size_t b12len,
const struct feature_set *our_features,
const struct chainparams *must_be_chain,
- char **fail);
+ const char **fail);
/**
* invrequest_encode - encode this complete bolt12 invreq TLV into text.
@@ -55,7 +55,7 @@ struct tlv_invoice_request *invrequest_decode(const tal_t *ctx,
const char *b12, size_t b12len,
const struct feature_set *our_features,
const struct chainparams *must_be_chain,
- char **fail);
+ const char **fail);
/**
* invoice_encode - encode this complete bolt12 invoice TLV into text.
@@ -81,7 +81,7 @@ struct tlv_invoice *invoice_decode(const tal_t *ctx,
const char *b12, size_t b12len,
const struct feature_set *our_features,
const struct chainparams *must_be_chain,
- char **fail);
+ const char **fail);
/* UINT64_MAX if no expiry. */
u64 invoice_expiry(const struct tlv_invoice *invoice);
@@ -91,7 +91,7 @@ struct tlv_invoice *invoice_decode_minimal(const tal_t *ctx,
const char *b12, size_t b12len,
const struct feature_set *our_features,
const struct chainparams *must_be_chain,
- char **fail);
+ const char **fail);
/* Check a bolt12-style signature. */
bool bolt12_check_signature(const struct tlv_field *fields,
@@ -167,6 +167,14 @@ struct tlv_invoice *invoice_for_invreq(const tal_t *ctx,
* types 240 through 1000 (inclusive). */
bool is_bolt12_signature_field(u64 typenum);
+/* Helper to convert bolt12 string (with expected HRP) to data */
+const u8 *b12_string_to_data(const tal_t *ctx,
+ const char *str,
+ size_t str_len,
+ const char *hrp_expected,
+ size_t *dlen,
+ const char **fail);
+
/**
* Return the first field (if any) outside the inclusive ranges.
*/
diff --git a/common/test/run-bolt11.c b/common/test/run-bolt11.c
index 33b228bc..a3c4c3a2 100644
--- a/common/test/run-bolt11.c
+++ b/common/test/run-bolt11.c
@@ -183,7 +183,8 @@ static void test_b11(const char *b11str,
const char *hashed_desc)
{
struct bolt11 *b11;
- char *fail, *reproduce;
+ const char *fail;
+ char *reproduce;
struct bolt11_field *b11_extra, *expect_extra;
b11 = bolt11_decode(tmpctx, b11str, NULL, hashed_desc,
@@ -287,7 +288,7 @@ int main(int argc, char *argv[])
struct amount_msat msatoshi;
const char *badstr;
struct bolt11_field *extra;
- char *fail;
+ const char *fail;
struct feature_set *fset;
common_setup(argv[0]);
diff --git a/common/test/run-bolt12-encode-test.c b/common/test/run-bolt12-encode-test.c
index 9391b1a3..aff41967 100644
--- a/common/test/run-bolt12-encode-test.c
+++ b/common/test/run-bolt12-encode-test.c
@@ -99,7 +99,7 @@ static void print_valid_offer(const struct tlv_offer *offer,
const char *extradesc,
const struct tlv_field *extrafield)
{
- char *str = offer_encode(tmpctx, offer), *err;
+ const char *str = offer_encode(tmpctx, offer), *err;
struct tlv_offer *offer2;
/* We only use extrafield on the end */
diff --git a/common/test/run-bolt12-offer-decode.c b/common/test/run-bolt12-offer-decode.c
index 5c2a73d5..059b2a88 100644
--- a/common/test/run-bolt12-offer-decode.c
+++ b/common/test/run-bolt12-offer-decode.c
@@ -156,7 +156,7 @@ int main(int argc, char *argv[])
json_for_each_arr(i, t, toks) {
bool valid;
const char *desc, *bolt12;
- char *fail;
+ const char *fail;
struct tlv_offer *offer;
assert(json_scan(tmpctx, json, t,
diff --git a/common/test/run-bolt12_decode.c b/common/test/run-bolt12_decode.c
index f27f8734..718f2a9e 100644
--- a/common/test/run-bolt12_decode.c
+++ b/common/test/run-bolt12_decode.c
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
json_for_each_arr(i, t, toks) {
bool valid, actual;
const jsmntok_t *strtok;
- char *fail;
+ const char *fail;
const char *str;
size_t dlen;
@@ -199,8 +199,8 @@ int main(int argc, char *argv[])
strtok = json_get_member(json, t, "string");
str = json_escape_unescape_len(tmpctx, json + strtok->start,
strtok->end - strtok->start);
- actual = (string_to_data(tmpctx, str, strlen(str),
- "lno", &dlen, &fail) != NULL);
+ actual = (b12_string_to_data(tmpctx, str, strlen(str),
+ "lno", &dlen, &fail) != NULL);
assert(actual == valid);
printf("%s %s\n", str, valid ? "OK": "INVALID");
}
diff --git a/common/test/run-bolt12_merkle.c b/common/test/run-bolt12_merkle.c
index abc54687..902268de 100644
--- a/common/test/run-bolt12_merkle.c
+++ b/common/test/run-bolt12_merkle.c
@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
struct pubkey alice, bob;
struct sha256 sha;
secp256k1_keypair kp;
- char *fail;
+ const char *fail;
common_setup(argv[0]);
/* Note: no nul term */
diff --git a/devtools/bolt11-cli.c b/devtools/bolt11-cli.c
index 17a7fa6b..272ec708 100644
--- a/devtools/bolt11-cli.c
+++ b/devtools/bolt11-cli.c
@@ -220,7 +220,8 @@ int main(int argc, char *argv[])
const char *method;
struct bolt11 *b11;
struct bolt11_field *extra;
- char *fail, *description = NULL;
+ const char *fail;
+ char *description = NULL;
common_setup(argv[0]);
diff --git a/devtools/bolt12-cli.c b/devtools/bolt12-cli.c
index c37cfd25..eca58467 100644
--- a/devtools/bolt12-cli.c
+++ b/devtools/bolt12-cli.c
@@ -717,7 +717,7 @@ int main(int argc, char *argv[])
const char *method;
char *hrp;
u8 *data;
- char *fail;
+ const char *fail;
bool to_hex = false;
common_setup(argv[0]);
diff --git a/lightningd/invoice.c b/lightningd/invoice.c
index f214b407..c27a0a6f 100644
--- a/lightningd/invoice.c
+++ b/lightningd/invoice.c
@@ -66,7 +66,7 @@ static void json_add_invoice_fields(struct json_stream *response,
json_add_u64(response, "expires_at", inv->expiry_time);
if (inv->local_offer_id) {
- char *fail;
+ const char *fail;
struct tlv_invoice *tinv;
json_add_sha256(response, "local_offer_id", inv->local_offer_id);
@@ -1334,7 +1334,7 @@ static struct command_result *json_listinvoices(struct command *cmd,
enum wait_index *listindex;
u64 *liststart;
u32 *listlimit;
- char *fail;
+ const char *fail;
if (!param_check(cmd, buffer, params,
p_opt("label", param_label, &label),
@@ -1671,7 +1671,7 @@ static struct command_result *json_createinvoice(struct command *cmd,
struct sha256 hash;
const u5 *sig;
bool have_n;
- char *fail;
+ const char *fail;
if (!param_check(cmd, buffer, params,
p_req("invstring", param_invstring, &invstring),
@@ -1956,7 +1956,7 @@ static struct command_result *json_signinvoice(struct command *cmd,
struct sha256 hash;
const u5 *sig;
bool have_n;
- char *fail;
+ const char *fail;
if (!param_check(cmd, buffer, params,
p_req("invstring", param_invstring, &invstring),
diff --git a/lightningd/offer.c b/lightningd/offer.c
index 78ea5f79..1ba82d78 100644
--- a/lightningd/offer.c
+++ b/lightningd/offer.c
@@ -32,9 +32,9 @@ static const char *offer_description_from_b12(const tal_t *ctx,
const char *b12)
{
struct tlv_offer *offer;
- char *fail;
+ const char *fail;
- offer = offer_decode(ctx, b12, strlen(b12),
+ offer = offer_decode(ctx, b12, strlen(b12),
NULL, NULL, &fail);
if (!offer) {
log_debug(ld->log, "Failed to decode BOLT12: %s", fail);
@@ -53,7 +53,7 @@ static struct command_result *param_b12_offer(struct command *cmd,
const jsmntok_t *tok,
struct tlv_offer **offer)
{
- char *fail;
+ const char *fail;
*offer = offer_decode(cmd, buffer + tok->start,
tok->end - tok->start,
cmd->ld->our_features, chainparams, &fail);
@@ -332,7 +332,7 @@ static struct command_result *prev_payment(struct command *cmd,
stmt = payments_next(cmd->ld->wallet, stmt)) {
const struct wallet_payment *payment;
const struct tlv_invoice *inv;
- char *fail;
+ const char *fail;
struct sha256 inv_oid;
payment = payment_get_details(tmpctx, stmt);
@@ -415,7 +415,7 @@ static struct command_result *param_b12_invreq(struct command *cmd,
const jsmntok_t *tok,
struct tlv_invoice_request **invreq)
{
- char *fail;
+ const char *fail;
*invreq = invrequest_decode(cmd, buffer + tok->start,
tok->end - tok->start,
diff --git a/lightningd/pay.c b/lightningd/pay.c
index 9fffd956..3f9a0128 100644
--- a/lightningd/pay.c
+++ b/lightningd/pay.c
@@ -1938,7 +1938,7 @@ static struct command_result *json_injectpaymentonion(struct command *cmd,
/* If we have and can decode invstring, we extract destination for listsendpays */
if (invstring) {
struct bolt11 *b11;
- char *fail;
+ const char *fail;
b11 = bolt11_decode(cmd, invstring, NULL, NULL, NULL, &fail);
if (b11) {
@@ -2229,7 +2229,7 @@ static struct command_result *json_listsendpays(struct command *cmd,
if (invstring) {
struct bolt11 *b11;
- char *fail;
+ const char *fail;
b11 = bolt11_decode(cmd, invstring, cmd->ld->our_features, NULL,
chainparams, &fail);
diff --git a/lightningd/runes.c b/lightningd/runes.c
index 36a4b10d..2c48e1f3 100644
--- a/lightningd/runes.c
+++ b/lightningd/runes.c
@@ -773,7 +773,7 @@ static const char *check_inv_condition(const tal_t *ctx,
{
const char *invfield = alt->fieldname + strlen("pinv");
const char *param;
- char *b11fail, *b12fail;
+ const char *b11fail, *b12fail;
const struct bolt11 *b11;
const struct tlv_invoice *b12;
enum invoice_field invf;
diff --git a/plugins/bkpr/bookkeeper.c b/plugins/bkpr/bookkeeper.c
index 8f61df17..61b6796b 100644
--- a/plugins/bkpr/bookkeeper.c
+++ b/plugins/bkpr/bookkeeper.c
@@ -1057,7 +1057,8 @@ static char *do_account_close_checks(struct command *cmd,
static char *fetch_out_desc_invstr(const tal_t *ctx, const char *buf,
const jsmntok_t *tok, char **err)
{
- char *bolt, *desc, *fail;
+ char *bolt, *desc;
+ const char *fail;
/* It's a bolt11! Parse it out to a desc */
if (!json_scan(ctx, buf, tok, "{bolt11:%}",
diff --git a/plugins/fetchinvoice.c b/plugins/fetchinvoice.c
index c8b003dd..8ff374d5 100644
--- a/plugins/fetchinvoice.c
+++ b/plugins/fetchinvoice.c
@@ -440,7 +440,7 @@ static struct command_result *param_offer(struct command *cmd,
const jsmntok_t *tok,
struct tlv_offer **offer)
{
- char *fail;
+ const char *fail;
*offer = offer_decode(cmd, buffer + tok->start, tok->end - tok->start,
plugin_feature_set(cmd->plugin), chainparams,
@@ -682,7 +682,7 @@ static struct command_result *invreq_done(struct command *cmd,
{
struct tlv_onionmsg_tlv *payload;
const jsmntok_t *t;
- char *fail;
+ const char *fail;
const struct recurrence *recurrence;
/* Get invoice request */
@@ -1375,7 +1375,7 @@ static struct command_result *createinvoice_done(struct command *cmd,
{
struct tlv_onionmsg_tlv *payload;
const jsmntok_t *invtok = json_get_member(buf, result, "bolt12");
- char *fail;
+ const char *fail;
/* Replace invoice with signed one */
tal_free(sent->inv);
@@ -1436,7 +1436,7 @@ static struct command_result *param_invreq(struct command *cmd,
const jsmntok_t *tok,
struct tlv_invoice_request **invreq)
{
- char *fail;
+ const char *fail;
int badf;
struct sha256 merkle, sighash;
@@ -1662,7 +1662,7 @@ static struct command_result *param_raw_invreq(struct command *cmd,
const jsmntok_t *tok,
struct tlv_invoice_request **invreq)
{
- char *fail;
+ const char *fail;
*invreq = invrequest_decode(cmd, buffer + tok->start, tok->end - tok->start,
plugin_feature_set(cmd->plugin), chainparams,
diff --git a/plugins/offers.c b/plugins/offers.c
index 72624e94..75338340 100644
--- a/plugins/offers.c
+++ b/plugins/offers.c
@@ -514,7 +514,8 @@ struct decodable {
u8 *emergency_recover;
};
-static u8 *encrypted_decode(const tal_t *ctx, const char *str, char **fail) {
+static u8 *encrypted_decode(const tal_t *ctx, const char *str, const char **fail)
+{
if (strlen(str) < 8) {
*fail = tal_fmt(ctx, "invalid payload");
return NULL;
@@ -640,7 +641,7 @@ static struct command_result *param_decodable(struct command *cmd,
const jsmntok_t *token,
struct decodable *decodable)
{
- char *likely_fail = NULL, *fail;
+ const char *likely_fail = NULL, *fail;
jsmntok_t tok;
enum likely_type type;
diff --git a/plugins/offers_invreq_hook.c b/plugins/offers_invreq_hook.c
index 476fff48..f9672b06 100644
--- a/plugins/offers_invreq_hook.c
+++ b/plugins/offers_invreq_hook.c
@@ -548,7 +548,7 @@ static struct command_result *prev_invoice_done(struct command *cmd,
{
const jsmntok_t *status, *arr, *b12;
struct tlv_invoice *previnv;
- char *fail;
+ const char *fail;
/* Was it created? */
arr = json_get_member(buf, result, "invoices");
diff --git a/plugins/pay.c b/plugins/pay.c
index fae675f1..64bc4879 100644
--- a/plugins/pay.c
+++ b/plugins/pay.c
@@ -1259,7 +1259,7 @@ static struct command_result *json_pay(struct command *cmd,
struct payment *p;
const char *b11str;
struct bolt11 *b11;
- char *b11_fail, *b12_fail;
+ const char *b11_fail, *b12_fail;
u64 *maxfee_pct_millionths;
u32 *maxdelay;
struct amount_msat *exemptfee, *msat, *maxfee, *partial;
diff --git a/plugins/renepay/main.c b/plugins/renepay/main.c
index 04cfe99d..8c2d72e0 100644
--- a/plugins/renepay/main.c
+++ b/plugins/renepay/main.c
@@ -111,7 +111,7 @@ static struct command_result *json_renepaystatus(struct command *cmd,
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"BOLT12 invoices are not yet supported.");
- char *fail;
+ const char *fail;
struct bolt11 *b11 =
bolt11_decode(tmpctx, invstring, plugin_feature_set(cmd->plugin),
NULL, chainparams, &fail);
@@ -232,7 +232,7 @@ static struct command_result *json_renepay(struct command *cmd, const char *buf,
/* === Parse invoice === */
- char *fail;
+ const char *fail;
struct bolt11 *b11 = NULL;
struct tlv_invoice *b12 = NULL;
diff --git a/plugins/xpay/xpay.c b/plugins/xpay/xpay.c
index fb54d0e8..43f76d97 100644
--- a/plugins/xpay/xpay.c
+++ b/plugins/xpay/xpay.c
@@ -1767,7 +1767,7 @@ static struct command_result *check_offer_payable(struct command *cmd,
const char *offerstr,
const struct amount_msat *msat)
{
- char *err;
+ const char *err;
struct tlv_offer *b12offer = offer_decode(tmpctx,
offerstr,
strlen(offerstr),
@@ -1968,7 +1968,7 @@ static struct command_result *xpay_core(struct command *cmd,
struct node_id dstid;
u64 now, invexpiry;
struct out_req *req;
- char *err;
+ const char *err;
list_head_init(&payment->current_attempts);
list_head_init(&payment->past_attempts);
@@ -2352,8 +2352,7 @@ static bool calc_maxfee(struct command *cmd,
return false;
} else {
const struct bolt11 *b11;
- char *fail;
- const char *invstr;
+ const char *invstr, *fail;
/* We need to know total amount to calc fee */
if (!invstringtok)
diff --git a/tests/fuzz/bolt12.h b/tests/fuzz/bolt12.h
index 11892487..15754d0e 100644
--- a/tests/fuzz/bolt12.h
+++ b/tests/fuzz/bolt12.h
@@ -65,11 +65,11 @@ size_t LLVMFuzzerCustomMutator(u8 *fuzz_data, size_t size, size_t max_size,
size_t mutated_size;
char *encoded_data;
size_t encoded_size;
- char *fail;
+ const char *fail;
/* Decode the input. */
- decoded_data = string_to_data(tmpctx, (char *)fuzz_data, size,
- bech32_hrp, &decoded_size, &fail);
+ decoded_data = b12_string_to_data(tmpctx, (char *)fuzz_data, size,
+ bech32_hrp, &decoded_size, &fail);
if (!decoded_data)
return initial_input(fuzz_data, size, max_size);
if (decoded_size > max_size)
@@ -113,15 +113,15 @@ size_t LLVMFuzzerCustomCrossOver(const u8 *data1, size_t size1, const u8 *data2,
size_t mutated_size;
char *encoded_data;
size_t encoded_size;
- char *fail;
+ const char *fail;
/* Decode inputs. */
- decoded_data1 = string_to_data(tmpctx, (char *)data1, size1, bech32_hrp,
- &decoded_size1, &fail);
+ decoded_data1 = b12_string_to_data(tmpctx, (char *)data1, size1, bech32_hrp,
+ &decoded_size1, &fail);
if (!decoded_data1)
return cross_over_fail();
- decoded_data2 = string_to_data(tmpctx, (char *)data2, size2, bech32_hrp,
- &decoded_size2, &fail);
+ decoded_data2 = b12_string_to_data(tmpctx, (char *)data2, size2, bech32_hrp,
+ &decoded_size2, &fail);
if (!decoded_data2)
return cross_over_fail();
diff --git a/tests/fuzz/fuzz-bolt11.c b/tests/fuzz/fuzz-bolt11.c
index 6f706e04..8d7507d4 100644
--- a/tests/fuzz/fuzz-bolt11.c
+++ b/tests/fuzz/fuzz-bolt11.c
@@ -218,7 +218,7 @@ size_t LLVMFuzzerCustomCrossOver(const u8 *in1, size_t in1_size, const u8 *in2,
void run(const uint8_t *data, size_t size)
{
char *invoice_str = to_string(tmpctx, data, size);
- char *fail = NULL;
+ const char *fail = NULL;
struct bolt11 *b11 = bolt11_decode(tmpctx, invoice_str, NULL, NULL, NULL, &fail);
if (b11)
diff --git a/tests/fuzz/fuzz-bolt12-bech32-decode.c b/tests/fuzz/fuzz-bolt12-bech32-decode.c
index 43f5fd21..cd771f67 100644
--- a/tests/fuzz/fuzz-bolt12-bech32-decode.c
+++ b/tests/fuzz/fuzz-bolt12-bech32-decode.c
@@ -5,7 +5,7 @@
#include <stddef.h>
#include <tests/fuzz/libfuzz.h>
-/* Include bolt12.c directly, to gain access to string_to_data(). */
+/* Include bolt12.c directly, to gain access to b12_string_to_data(). */
#include "../../common/bolt12.c"
void init(int *argc, char ***argv)
@@ -18,9 +18,9 @@ void init(int *argc, char ***argv)
void run(const u8 *data, size_t size)
{
size_t dlen;
- char *fail;
+ const char *fail;
- string_to_data(tmpctx, (const char *)data, size, "lno", &dlen, &fail);
+ b12_string_to_data(tmpctx, (const char *)data, size, "lno", &dlen, &fail);
clean_tmpctx();
}
diff --git a/tests/fuzz/fuzz-bolt12-invoice-decode.c b/tests/fuzz/fuzz-bolt12-invoice-decode.c
index 20fde16e..40474314 100644
--- a/tests/fuzz/fuzz-bolt12-invoice-decode.c
+++ b/tests/fuzz/fuzz-bolt12-invoice-decode.c
@@ -9,7 +9,7 @@ const char *bech32_hrp = "lni";
void run(const u8 *data, size_t size)
{
- char *fail;
+ const char *fail;
invoice_decode(tmpctx, (const char *)data, size, /*feature_set=*/NULL,
/*must_be_chain=*/NULL, &fail);
diff --git a/tests/fuzz/fuzz-bolt12-invrequest-decode.c b/tests/fuzz/fuzz-bolt12-invrequest-decode.c
index 159fb26b..8c1a1121 100644
--- a/tests/fuzz/fuzz-bolt12-invrequest-decode.c
+++ b/tests/fuzz/fuzz-bolt12-invrequest-decode.c
@@ -183,7 +183,7 @@ do { \
void run(const u8 *data, size_t size)
{
struct tlv_invoice_request *invreq, *decoded_invreq;
- char *fail = NULL, *encoded_invreq;
+ const char *fail = NULL, *encoded_invreq;
invreq = invrequest_decode(tmpctx, (const char *)data, size,
/*feature_set=*/NULL, /*must_be_chain=*/NULL, &fail);
diff --git a/tests/fuzz/fuzz-bolt12-offer-decode.c b/tests/fuzz/fuzz-bolt12-offer-decode.c
index 4ab229c6..c4a8b81f 100644
--- a/tests/fuzz/fuzz-bolt12-offer-decode.c
+++ b/tests/fuzz/fuzz-bolt12-offer-decode.c
@@ -151,7 +151,7 @@ do { \
void run(const u8 *data, size_t size)
{
struct tlv_offer *offer, *decoded_offer;
- char *fail = NULL, *encoded_offer;
+ const char *fail = NULL, *encoded_offer;
offer = offer_decode(tmpctx, (const char *)data, size,
/*feature_set=*/NULL, /*must_be_chain=*/NULL, &fail);
Why this scored 22/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.