rgb-cln/cli
Rusty Russell 4ea1d13077 cli: handle OOM by directly streaming output.
We use raw malloc here, again, to handle the failure cases more easily.

I tested it with this hack, then ran the result through `jq --stream '.'`
before and after to make sure it was the same.

    diff --git a/cli/lightning-cli.c b/cli/lightning-cli.c
    index f840c0786..d83555a51 100644
    --- a/cli/lightning-cli.c
    +++ b/cli/lightning-cli.c
    @@ -295,6 +295,14 @@ static void oom_dump(int fd, char *resp, size_t resp_len, size_t off)
     	exit(0);
     }
     
    +static void *xrealloc(void *p, size_t len)
    +{
    +	if (len > 1000000)
    +		return NULL;
    +	return realloc(p, len);
    +}
    +#define realloc xrealloc
    +
     int main(int argc, char *argv[])
     {
     	setup_locale();

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-05-22 11:28:44 +00:00
..
test cli: handle OOM by directly streaming output. 2019-05-22 11:28:44 +00:00
Makefile lightning-cli: don't produce bad JSON if fields contain ". 2019-04-10 20:03:39 -07:00
lightning-cli.c cli: handle OOM by directly streaming output. 2019-05-22 11:28:44 +00:00