lightningd: fix handling of truncated config options.

Do the same thing '--help' does with them; append `...`.

Valgrind noticed that we weren't NUL-terminarting if answer was over
78 characters.

Changelog-Fixed: JSONRPC: listconfigs appends '...' to truncated config options.
This commit is contained in:
Rusty Russell
2019-11-23 12:16:58 +10:30
parent f5831e5d10
commit 14997f6237
2 changed files with 8 additions and 3 deletions

View File

@@ -732,13 +732,16 @@ def test_address(node_factory):
def test_listconfigs(node_factory, bitcoind, chainparams):
l1 = node_factory.get_node()
# Make extremely long entry, check it works
l1 = node_factory.get_node(options={'log-prefix': 'lightning1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'})
configs = l1.rpc.listconfigs()
# See utils.py
assert configs['allow-deprecated-apis'] is False
assert configs['network'] == chainparams['name']
assert configs['ignore-fee-limits'] is False
assert configs['ignore-fee-limits'] is False
assert configs['log-prefix'] == 'lightning1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...'
# Test one at a time.
for c in configs.keys():