From cabeef2d88c73e73f334cf823cbb719e0e6250aa Mon Sep 17 00:00:00 2001 From: ZmnSCPxj Date: Sun, 25 Feb 2018 15:37:01 +0000 Subject: [PATCH] lightning-cli: Be more discerning about literals. Fixes: #574 The issue states that we should follow the standard when parsing the port for IPv6 [addr]:port syntax, but this is actually already supported by the daemon. The issue arises due to the `lightning-cli` misinterpreting [addr]:port as an array. This modification makes [addr]:port interpreted as a string. --- cli/lightning-cli.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cli/lightning-cli.c b/cli/lightning-cli.c index 406639885..7d1f11fa3 100644 --- a/cli/lightning-cli.c +++ b/cli/lightning-cli.c @@ -131,13 +131,14 @@ static char *opt_set_ordered(enum input *input) static bool is_literal(const char *arg) { - return strspn(arg, "0123456789") == strlen(arg) + size_t arglen = strlen(arg); + return strspn(arg, "0123456789") == arglen || streq(arg, "true") || streq(arg, "false") || streq(arg, "null") - || arg[0] == '{' - || arg[0] == '[' - || arg[0] == '"'; + || (arg[0] == '{' && arg[arglen - 1] == '}') + || (arg[0] == '[' && arg[arglen - 1] == ']') + || (arg[0] == '"' && arg[arglen - 1] == '"'); } static void add_input(char **cmd, const char *input,