Skip to content

Commit aaf743e

Browse files
rustyrussellniftynei
authored andcommitted
commando: fix crash when rune is completely bogus.
The error routine returns a string literal in this case, which we can't take(). Reported-by: @jb55 Signed-off-by: Rusty Russell <[email protected]>
1 parent 43e5ef3 commit aaf743e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

plugins/commando.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,11 @@ static const char *check_rune(const tal_t *ctx,
344344
cinfo.params = params;
345345
cinfo.usage = NULL;
346346
strmap_init(&cinfo.cached_params);
347-
err = rune_test(ctx, master_rune, rune, check_condition, &cinfo);
347+
err = rune_test(tmpctx, master_rune, rune, check_condition, &cinfo);
348348
/* Just in case they manage to make us speak non-JSON, escape! */
349349
if (err)
350-
err = json_escape(ctx, take(err))->s;
350+
err = json_escape(ctx, err)->s;
351+
351352
strmap_clear(&cinfo.cached_params);
352353

353354
/* If it succeeded, *now* we increment any associated usage counter. */

tests/test_plugin.py

+8
Original file line numberDiff line numberDiff line change
@@ -2559,6 +2559,14 @@ def test_commando(node_factory, executor):
25592559
fut.result(10)
25602560

25612561
rune = l1.rpc.commando_rune()['rune']
2562+
2563+
# Bad rune fails
2564+
with pytest.raises(RpcError, match="Not authorized: Not derived from master"):
2565+
l2.rpc.call(method='commando',
2566+
payload={'peer_id': l1.info['id'],
2567+
'rune': 'VXY4AAkrPyH2vzSvOHnI7PDVfS6O04bRQLUCIUFJD5Y9NjQmbWV0aG9kPWludm9pY2UmcmF0ZT0yMZ==',
2568+
'method': 'listpeers'})
2569+
25622570
# This works
25632571
res = l2.rpc.call(method='commando',
25642572
payload={'peer_id': l1.info['id'],

0 commit comments

Comments
 (0)