diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2013-06-08 12:10:52 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2013-06-08 12:14:38 +0200 |
commit | a6b0c13b1891667a27a8d60506456b288d3f0faa (patch) | |
tree | db64289d45934dbf6a16500515b3390b0f269310 /ubus.c | |
parent | 849f89381896b9654ae4bc6bc0057a0d94980fe4 (diff) |
ubus: duplicate request buffer to avoid memory corruption with multiple requests
Diffstat (limited to 'ubus.c')
-rw-r--r-- | ubus.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -368,10 +368,12 @@ static bool parse_json_rpc(struct rpc_data *d, struct blob_attr *data) if (!cur) return true; - d->params = cur; + d->params = blob_memdup(cur); + if (!d->params) + return false; blobmsg_parse_array(data_policy, ARRAY_SIZE(data_policy), tb2, - blobmsg_data(cur), blobmsg_data_len(cur)); + blobmsg_data(d->params), blobmsg_data_len(d->params)); if (tb2[0]) d->object = blobmsg_data(tb2[0]); @@ -465,11 +467,11 @@ static void uh_ubus_handle_request_object(struct client *cl, struct json_object } uh_ubus_send_request(cl, obj, data.data); - return; + goto out; } else if (!strcmp(data.method, "list")) { uh_ubus_send_list(cl, obj, data.params); - return; + goto out; } else { err = ERROR_METHOD; @@ -478,6 +480,9 @@ static void uh_ubus_handle_request_object(struct client *cl, struct json_object error: uh_ubus_json_error(cl, err); +out: + if (data.params) + free(data.params); } static void __uh_ubus_next_batched_request(struct uloop_timeout *timeout) |