json-rpc: Return a standard compliant error when parsing fails

The JSON-RPC spec specifies that if the request is unparseable we
should return an error with a NULL id. This is a bit more friendly
than slamming the door in the face.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2018-02-08 21:46:34 +01:00
parent e92e26f84d
commit 5a133d2d70

View File

@ -660,7 +660,10 @@ again:
log_unusual(jcon->ld->log,
"Invalid token in json input: '%.*s'",
(int)jcon->used, jcon->buffer);
return io_close(conn);
json_command_malformed(
jcon, NULL,
"Invalid token in json input");
return io_halfclose(conn);
}
/* We need more. */
goto read_more;