@@ -1041,7 +1041,9 @@ REGISTER_PLUGIN_HOOK(rpc_command,
10411041/* We return struct command_result so command_fail return value has a natural
10421042 * sink; we don't actually use the result. */
10431043static struct command_result *
1044- parse_request (struct json_connection * jcon , const jsmntok_t tok [])
1044+ parse_request (struct json_connection * jcon ,
1045+ const char * buffer ,
1046+ const jsmntok_t tok [])
10451047{
10461048 const jsmntok_t * method , * id , * params , * filter , * jsonrpc ;
10471049 struct command * c ;
@@ -1054,10 +1056,10 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
10541056 return NULL ;
10551057 }
10561058
1057- method = json_get_member (jcon -> buffer , tok , "method" );
1058- params = json_get_member (jcon -> buffer , tok , "params" );
1059- filter = json_get_member (jcon -> buffer , tok , "filter" );
1060- id = json_get_member (jcon -> buffer , tok , "id" );
1059+ method = json_get_member (buffer , tok , "method" );
1060+ params = json_get_member (buffer , tok , "params" );
1061+ filter = json_get_member (buffer , tok , "filter" );
1062+ id = json_get_member (buffer , tok , "id" );
10611063
10621064 if (!id ) {
10631065 json_command_malformed (jcon , "null" , "No id" );
@@ -1070,8 +1072,8 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
10701072 return NULL ;
10711073 }
10721074
1073- jsonrpc = json_get_member (jcon -> buffer , tok , "jsonrpc" );
1074- if (!jsonrpc || jsonrpc -> type != JSMN_STRING || !json_tok_streq (jcon -> buffer , jsonrpc , "2.0" )) {
1075+ jsonrpc = json_get_member (buffer , tok , "jsonrpc" );
1076+ if (!jsonrpc || jsonrpc -> type != JSMN_STRING || !json_tok_streq (buffer , jsonrpc , "2.0" )) {
10751077 json_command_malformed (jcon , "null" , "jsonrpc: \"2.0\" must be specified in the request" );
10761078 return NULL ;
10771079 }
@@ -1087,7 +1089,7 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
10871089 c -> id_is_string = (id -> type == JSMN_STRING );
10881090 /* Include "" around string */
10891091 c -> id = tal_strndup (c ,
1090- json_tok_full (jcon -> buffer , id ),
1092+ json_tok_full (buffer , id ),
10911093 json_tok_full_len (id ));
10921094 c -> mode = CMD_NORMAL ;
10931095 c -> filter = NULL ;
@@ -1106,7 +1108,7 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
11061108
11071109 if (filter ) {
11081110 struct command_result * ret ;
1109- ret = parse_filter (c , "filter" , jcon -> buffer , filter );
1111+ ret = parse_filter (c , "filter" , buffer , filter );
11101112 if (ret )
11111113 return ret ;
11121114 }
@@ -1115,31 +1117,31 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
11151117 * actually just logging the id */
11161118 log_io (jcon -> log , LOG_IO_IN , NULL , c -> id , NULL , 0 );
11171119
1118- c -> json_cmd = find_cmd (jcon -> ld -> jsonrpc , jcon -> buffer , method );
1120+ c -> json_cmd = find_cmd (jcon -> ld -> jsonrpc , buffer , method );
11191121 if (!c -> json_cmd ) {
11201122 return command_fail (
11211123 c , JSONRPC2_METHOD_NOT_FOUND , "Unknown command '%.*s'" ,
1122- method -> end - method -> start , jcon -> buffer + method -> start );
1124+ method -> end - method -> start , buffer + method -> start );
11231125 }
11241126 if (!command_deprecated_in_ok (c , NULL ,
11251127 c -> json_cmd -> depr_start ,
11261128 c -> json_cmd -> depr_end )) {
11271129 return command_fail (c , JSONRPC2_METHOD_NOT_FOUND ,
11281130 "Command %.*s is deprecated" ,
11291131 json_tok_full_len (method ),
1130- json_tok_full (jcon -> buffer , method ));
1132+ json_tok_full (buffer , method ));
11311133 }
11321134 if (c -> json_cmd -> dev_only && !jcon -> ld -> developer ) {
11331135 return command_fail (c , JSONRPC2_METHOD_NOT_FOUND ,
11341136 "Command %.*s is developer-only" ,
11351137 json_tok_full_len (method ),
1136- json_tok_full (jcon -> buffer , method ));
1138+ json_tok_full (buffer , method ));
11371139 }
11381140
11391141 rpc_hook = tal (c , struct rpc_command_hook_payload );
11401142 rpc_hook -> cmd = c ;
11411143 /* Duplicate since we might outlive the connection */
1142- json_dup_contents (rpc_hook , jcon -> buffer , tok ,
1144+ json_dup_contents (rpc_hook , buffer , tok ,
11431145 & rpc_hook -> buffer ,
11441146 & rpc_hook -> request );
11451147
@@ -1257,7 +1259,7 @@ static struct io_plan *read_json(struct io_conn *conn,
12571259 db_begin_transaction (jcon -> ld -> wallet -> db );
12581260 in_transaction = true;
12591261 }
1260- parse_request (jcon , jcon -> input_toks );
1262+ parse_request (jcon , jcon -> buffer , jcon -> input_toks );
12611263
12621264 /* Remove first {}. */
12631265 memmove (jcon -> buffer , jcon -> buffer + jcon -> input_toks [0 ].end ,
0 commit comments