projects
/
project
/
ubus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
CMakeLists.txt: bump minimum cmake version
[project/ubus.git]
/
libubus-obj.c
diff --git
a/libubus-obj.c
b/libubus-obj.c
index b3019652c52d73a1f9e1c6d24abb821161f2a198..29cbb2b98e6eab48d8cd280e6ca2a596da1ff729 100644
(file)
--- a/
libubus-obj.c
+++ b/
libubus-obj.c
@@
-31,7
+31,8
@@
ubus_process_unsubscribe(struct ubus_context *ctx, struct ubus_msghdr *hdr,
if (s->remove_cb)
s->remove_cb(ctx, s, blob_get_u32(attrbuf[UBUS_ATTR_TARGET]));
if (s->remove_cb)
s->remove_cb(ctx, s, blob_get_u32(attrbuf[UBUS_ATTR_TARGET]));
- close(fd);
+ if (fd >= 0)
+ close(fd);
}
static void
}
static void
@@
-45,7
+46,8
@@
ubus_process_notify(struct ubus_context *ctx, struct ubus_msghdr *hdr,
if (obj->subscribe_cb)
obj->subscribe_cb(ctx, obj);
if (obj->subscribe_cb)
obj->subscribe_cb(ctx, obj);
- close(fd);
+ if (fd >= 0)
+ close(fd);
}
static void
ubus_process_invoke(struct ubus_context *ctx, struct ubus_msghdr *hdr,
}
static void
ubus_process_invoke(struct ubus_context *ctx, struct ubus_msghdr *hdr,
@@
-72,7
+74,7
@@
ubus_process_invoke(struct ubus_context *ctx, struct ubus_msghdr *hdr,
if (attrbuf[UBUS_ATTR_NO_REPLY])
no_reply = blob_get_int8(attrbuf[UBUS_ATTR_NO_REPLY]);
if (attrbuf[UBUS_ATTR_NO_REPLY])
no_reply = blob_get_int8(attrbuf[UBUS_ATTR_NO_REPLY]);
-
+
req.peer = hdr->peer;
req.seq = hdr->seq;
req.object = obj->id;
req.peer = hdr->peer;
req.seq = hdr->seq;
req.object = obj->id;
@@
-92,6
+94,11
@@
ubus_process_invoke(struct ubus_context *ctx, struct ubus_msghdr *hdr,
goto send;
found:
goto send;
found:
+ if (!attrbuf[UBUS_ATTR_DATA]) {
+ ret = UBUS_STATUS_INVALID_ARGUMENT;
+ goto send;
+ }
+
ret = obj->methods[method].handler(ctx, obj, &req,
blob_data(attrbuf[UBUS_ATTR_METHOD]),
attrbuf[UBUS_ATTR_DATA]);
ret = obj->methods[method].handler(ctx, obj, &req,
blob_data(attrbuf[UBUS_ATTR_METHOD]),
attrbuf[UBUS_ATTR_DATA]);
@@
-114,7
+121,7
@@
void __hidden ubus_process_obj_msg(struct ubus_context *ctx, struct ubus_msghdr_
struct ubus_object *obj;
uint32_t objid;
void *prev_data = NULL;
struct ubus_object *obj;
uint32_t objid;
void *prev_data = NULL;
- attrbuf = ubus_parse_msg(buf->data);
+ attrbuf = ubus_parse_msg(buf->data
, blob_raw_len(buf->data)
);
if (!attrbuf[UBUS_ATTR_OBJID])
return;
if (!attrbuf[UBUS_ATTR_OBJID])
return;
@@
-153,7
+160,7
@@
void __hidden ubus_process_obj_msg(struct ubus_context *ctx, struct ubus_msghdr_
static void ubus_add_object_cb(struct ubus_request *req, int type, struct blob_attr *msg)
{
struct ubus_object *obj = req->priv;
static void ubus_add_object_cb(struct ubus_request *req, int type, struct blob_attr *msg)
{
struct ubus_object *obj = req->priv;
- struct blob_attr **attrbuf = ubus_parse_msg(msg);
+ struct blob_attr **attrbuf = ubus_parse_msg(msg
, blob_raw_len(msg)
);
if (!attrbuf[UBUS_ATTR_OBJID])
return;
if (!attrbuf[UBUS_ATTR_OBJID])
return;
@@
-233,7
+240,7
@@
int ubus_add_object(struct ubus_context *ctx, struct ubus_object *obj)
static void ubus_remove_object_cb(struct ubus_request *req, int type, struct blob_attr *msg)
{
struct ubus_object *obj = req->priv;
static void ubus_remove_object_cb(struct ubus_request *req, int type, struct blob_attr *msg)
{
struct ubus_object *obj = req->priv;
- struct blob_attr **attrbuf = ubus_parse_msg(msg);
+ struct blob_attr **attrbuf = ubus_parse_msg(msg
, blob_raw_len(msg)
);
if (!attrbuf[UBUS_ATTR_OBJID])
return;
if (!attrbuf[UBUS_ATTR_OBJID])
return;