Skip to content

Commit 7983aaf

Browse files
committed
lightningd: fix segfault when parse_filter fails
1 parent 22f7a62 commit 7983aaf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lightningd/jsonrpc.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,13 @@ parse_request(struct json_connection *jcon,
10701070
"Expected string for method");
10711071
}
10721072

1073+
c->json_cmd = find_cmd(jcon->ld->jsonrpc, buffer, method);
1074+
if (!c->json_cmd) {
1075+
return command_fail(
1076+
c, JSONRPC2_METHOD_NOT_FOUND, "Unknown command '%.*s'",
1077+
method->end - method->start, buffer + method->start);
1078+
}
1079+
10731080
if (filter) {
10741081
struct command_result *ret;
10751082
ret = parse_filter(c, "filter", buffer, filter);
@@ -1081,12 +1088,6 @@ parse_request(struct json_connection *jcon,
10811088
* actually just logging the id */
10821089
log_io(jcon->log, LOG_IO_IN, NULL, c->id, NULL, 0);
10831090

1084-
c->json_cmd = find_cmd(jcon->ld->jsonrpc, buffer, method);
1085-
if (!c->json_cmd) {
1086-
return command_fail(
1087-
c, JSONRPC2_METHOD_NOT_FOUND, "Unknown command '%.*s'",
1088-
method->end - method->start, buffer + method->start);
1089-
}
10901091
if (!command_deprecated_in_ok(c, NULL,
10911092
c->json_cmd->depr_start,
10921093
c->json_cmd->depr_end)) {

0 commit comments

Comments
 (0)