From 6e79e2104c95e005e81a070053a3dc99a2bfde09 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 13 Nov 2009 15:05:19 -0800 Subject: [PATCH] ovsdb: Fix use of non-array for JSON-RPC parameters. JSON-RPC requires that "params" be an array, but we weren't observing this properly in the ovsdb specifications or code. Thanks to Jeremy Stribling for pointing out the problem. --- ovsdb/SPECS | 10 +++++++--- ovsdb/jsonrpc-server.c | 15 +++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ovsdb/SPECS b/ovsdb/SPECS index f0d7748ff..ae4d649b6 100644 --- a/ovsdb/SPECS +++ b/ovsdb/SPECS @@ -32,6 +32,10 @@ values. Additional notation is presented later. A JSON number with an integer value, within a certain range (currently -2**63...+2**63-1). + + + Any JSON value. + Schema Format ------------- @@ -255,7 +259,7 @@ cancel Request object members: "method": "cancel" required - "params": the "id" for an outstanding request required + "params": [the "id" for an outstanding request] required "id": null required Response object members: @@ -283,8 +287,8 @@ echo Request object members: "method": "echo" required - "params": any JSON value required - "id": any JSON value required + "params": JSON array with any contents required + "id": required Response object members: diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index 7a33d77af..cea5ddc72 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -368,7 +368,7 @@ ovsdb_jsonrpc_session_run(struct ovsdb_jsonrpc_session *s) case RECONNECT_PROBE: if (s->rpc) { - struct json *params = json_integer_create(0); + struct json *params = json_array_create_empty(); jsonrpc_send(s->rpc, jsonrpc_create_request("echo", params)); } break; @@ -453,12 +453,15 @@ ovsdb_jsonrpc_session_got_request(struct ovsdb_jsonrpc_session *s, static void execute_cancel(struct ovsdb_jsonrpc_session *s, struct jsonrpc_msg *request) { - size_t hash = json_hash(request->id, 0); - struct ovsdb_jsonrpc_trigger *t; + if (json_array(request->params)->n == 1) { + struct ovsdb_jsonrpc_trigger *t; + struct json *id; - t = ovsdb_jsonrpc_trigger_find(s, request->params, hash); - if (t) { - ovsdb_jsonrpc_trigger_complete(t); + id = request->params->u.array.elems[0]; + t = ovsdb_jsonrpc_trigger_find(s, id, json_hash(id, 0)); + if (t) { + ovsdb_jsonrpc_trigger_complete(t); + } } } -- 2.43.0