mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
jsonrpc: make sure even errors are valid json.
We often quote their msg in our reply; sanitize it! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
164c76454c
commit
aee2197a66
@@ -480,13 +480,13 @@ struct json_stream *json_stream_fail_nodata(struct command *cmd,
|
||||
const char *errmsg)
|
||||
{
|
||||
struct json_stream *r = json_start(cmd);
|
||||
struct json_escaped *e = json_partial_escape(tmpctx, errmsg);
|
||||
|
||||
assert(code);
|
||||
assert(errmsg);
|
||||
|
||||
json_stream_append_fmt(r, " \"error\" : "
|
||||
"{ \"code\" : %d,"
|
||||
" \"message\" : \"%s\"", code, errmsg);
|
||||
" \"message\" : \"%s\"", code, e->s);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user