remove support for path based invoke, add object id validation for responses
This commit is contained in:
parent
7b262aec38
commit
a03acea49c
1 changed files with 16 additions and 11 deletions
|
@ -167,24 +167,19 @@ static int ubusd_handle_invoke(struct ubus_client *cl, struct ubus_msg_buf *ub)
|
||||||
{
|
{
|
||||||
struct ubus_object *obj = NULL;
|
struct ubus_object *obj = NULL;
|
||||||
struct blob_attr **attr;
|
struct blob_attr **attr;
|
||||||
|
struct ubus_id *id;
|
||||||
const char *method;
|
const char *method;
|
||||||
|
|
||||||
attr = ubus_parse_msg(ub->data);
|
attr = ubus_parse_msg(ub->data);
|
||||||
if (!attr[UBUS_ATTR_METHOD])
|
if (!attr[UBUS_ATTR_METHOD] || !attr[UBUS_ATTR_OBJID])
|
||||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||||
|
|
||||||
if (attr[UBUS_ATTR_OBJID]) {
|
id = ubus_find_id(&objects, blob_get_int32(attr[UBUS_ATTR_OBJID]));
|
||||||
struct ubus_id *id;
|
if (!id)
|
||||||
id = ubus_find_id(&objects, blob_get_int32(attr[UBUS_ATTR_OBJID]));
|
|
||||||
if (id)
|
|
||||||
obj = container_of(id, struct ubus_object, id);
|
|
||||||
} else if (attr[UBUS_ATTR_OBJPATH]) {
|
|
||||||
const char *objpath = blob_data(attr[UBUS_ATTR_OBJPATH]);
|
|
||||||
obj = avl_find_element(&path, objpath, obj, path);
|
|
||||||
}
|
|
||||||
if (!obj)
|
|
||||||
return UBUS_STATUS_NOT_FOUND;
|
return UBUS_STATUS_NOT_FOUND;
|
||||||
|
|
||||||
|
obj = container_of(id, struct ubus_object, id);
|
||||||
|
|
||||||
method = blob_data(attr[UBUS_ATTR_METHOD]);
|
method = blob_data(attr[UBUS_ATTR_METHOD]);
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id.id);
|
blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id.id);
|
||||||
|
@ -209,11 +204,21 @@ static int ubusd_handle_invoke(struct ubus_client *cl, struct ubus_msg_buf *ub)
|
||||||
static int ubusd_handle_status(struct ubus_client *cl, struct ubus_msg_buf *ub)
|
static int ubusd_handle_status(struct ubus_client *cl, struct ubus_msg_buf *ub)
|
||||||
{
|
{
|
||||||
struct blob_attr **attr;
|
struct blob_attr **attr;
|
||||||
|
struct ubus_object *obj;
|
||||||
|
struct ubus_id *id;
|
||||||
|
|
||||||
attr = ubus_parse_msg(ub->data);
|
attr = ubus_parse_msg(ub->data);
|
||||||
if (!attr[UBUS_ATTR_OBJID] || !attr[UBUS_ATTR_STATUS])
|
if (!attr[UBUS_ATTR_OBJID] || !attr[UBUS_ATTR_STATUS])
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
id = ubus_find_id(&objects, blob_get_int32(attr[UBUS_ATTR_OBJID]));
|
||||||
|
if (!id)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
obj = container_of(id, struct ubus_object, id);
|
||||||
|
if (cl != obj->client)
|
||||||
|
goto error;
|
||||||
|
|
||||||
cl = ubusd_get_client_by_id(ub->hdr.peer);
|
cl = ubusd_get_client_by_id(ub->hdr.peer);
|
||||||
if (!cl)
|
if (!cl)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Reference in a new issue