summaryrefslogtreecommitdiff
path: root/libubus-req.c
Commit message (Collapse)AuthorAgeFilesLines
* fix blob parsing vulnerability by using blob_parse_untrustedPetr Štetiar2019-12-191-3/+3
| | | | | | | | | | blob_parse expects blobs from trusted inputs, but it can be supplied with possibly malicious blobs from untrusted inputs as well, which might lead to undefined behaviour and/or crash of ubus daemon. In order to prevent such conditions, switch to blob_parse_untrusted which should hopefully handle such untrusted inputs appropriately. Signed-off-by: Petr Štetiar <ynezz@true.cz>
* workaround possibly false positive uses of memory after it is freedPetr Štetiar2019-12-191-4/+2
| | | | | | | | | | | | | | | | | | scan-build from clang-9 has reported following: libubox/list.h:83:22: warning: Use of memory after it is freed entry->next->prev = entry->prev; ^~~~~~~~~~~ ubusd_event.c:42:3: warning: Use of memory after it is freed ubusd_delete_event_source(ev); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Which might be a false positives, but in order to make the code pass the static analyzer checks, rewrite the while loops on lists with the safe list iterator. Signed-off-by: Petr Štetiar <ynezz@true.cz>
* iron out all extra compiler warningsPetr Štetiar2019-12-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | clang-9 on x86/64 has reported following warnings/errors: libubus-acl.c:123:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] libubus-io.c:108:18: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] libubus-io.c:395:56: error: comparison of integers of different signs: 'ssize_t' (aka 'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] libubus-req.c:441:4: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:119:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd_acl.c:152:5: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:348:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:352:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:357:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:362:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:367:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] ubusd_acl.c:447:16: error: comparison of integers of different signs: 'int' and '__size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] ubusd_acl.c:502:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd.c:123:13: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd.c:170:15: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd.c:262:43: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd.c:287:30: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd_event.c:170:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare] ubusd_obj.c:71:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] Signed-off-by: Petr Štetiar <ynezz@true.cz>
* libubus: pass an empty UBUS_ATTR_DATA block if msg is NULL on invokeFelix Fietkau2018-07-261-6/+11
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libubus: check for non-NULL data before running callbacksFelix Fietkau2018-07-251-0/+3
| | | | | | | | UBUS_MSG_INVOKE and UBUS_MSG_DATA can be sent without UBUS_ATTR_DATA present. Most ubus users assume that the msg argument passed can never be NULL, so this change prevents a crash Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libubus-req: add data_cb callback handling for ubus notificationsJohn Crispin2017-11-061-0/+13
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* libubus: do not modify uloop_cancelledFelix Fietkau2017-02-031-7/+5
| | | | | | | | | | | | uloop_cancelled was used for two purposes within ubus_complete_request: - interrupting recursive requests on SIGINT/SIGTERM - breaking out of the poll loop in a recursive request that completed Saving/restorung uloop_cancelled was buggy, leading to SIGTERM not being processed properly. Simplify the logic by using a separate field for internal use Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libubus: do not register/unregister with uloop during sync requestsFelix Fietkau2017-01-221-11/+2
| | | | | | | This was leftover code from before this codepath was converted to polling directly Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libubus: move uloop_init() call to ubus_connect_ctxFelix Fietkau2017-01-221-1/+0
| | | | | | uloop should not be used before it is initialized Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libubus: reduce code duplication, fix indentationFelix Fietkau2016-12-241-36/+5
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* Allow sending a fd along a ubus_requestamine ahd2016-12-241-3/+47
| | | | Signed-off-by: amine.ahd <amine.ahd@gmail.com>
* libubus: add socket EOF handling to ubus_complete_request()Felix Fietkau2015-12-091-0/+4
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: add monitor supportFelix Fietkau2015-11-191-0/+6
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: fix processing queued messages after blocking requestsFelix Fietkau2015-01-221-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: restore uloop_cancelled on timeoutAlexandru Ardelean2014-09-151-0/+1
| | | | | | | Context: 1 loop with a single ubus_invoke() that times out calls uloop_end() which ends the loop, and thus ends the application. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: remove ubus_msghdr_data() by passing in the right data structure ↵Felix Fietkau2014-09-151-18/+18
| | | | | | pointer Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: fix ubus_invoke() to return err in case ubus_start_request() failsAlexandru Ardelean2014-07-031-1/+5
| | | | | | | Seems the UBUS_MAX_MSGLEN is ignored by ubus_invoke(), and then segfault happens. This issue is present before this set of patches.
* libubus: fix deferring invoke processing for non-uloop usageFelix Fietkau2014-06-251-1/+5
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: always defer processing incoming invoke/unsubscribe/notify if there ↵Felix Fietkau2014-06-241-3/+0
| | | | | | | | | is a request pending This fixes recursion problems on config reload in netifd and simplifies application handling of requests Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: do not use uloop_run() inside ubus_complete_requestFelix Fietkau2014-03-181-21/+21
| | | | | | Avoid unrelated uloop callbacks by using poll() on the ubus fd instead. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: implement file descriptor passing supportFelix Fietkau2014-02-181-5/+13
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: pull the variable length data array out of struct ubus_msghdr to ↵Felix Fietkau2013-10-291-5/+6
| | | | | | fix builds with clang Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: fix logic inversion for cancelling requestsFelix Fietkau2013-05-301-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: fix deadlock in recursive synchronous ubus requestsFelix Fietkau2013-05-111-0/+2
| | | | | | | | | | | | | When synchronous request completion loops are running, the innermost loop can receive events that can unblock the outer loops, however the loop clears uloop_cancelled (which is set by the request completion). This causes the event loop to continue running even while a completion loop has already been unblocked. Fix this by not clearing uloop_cancelled for inner loops Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: fix synchronous ubus_notify without waiting for a timeoutFelix Fietkau2013-03-171-1/+3
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: fix uninitialized variable warningFelix Fietkau2012-12-151-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: implement notify handlingFelix Fietkau2012-12-151-5/+140
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: fix segfaults on request timeoutsFelix Fietkau2012-12-151-19/+26
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* move ubus_start_request to libubus-req.cFelix Fietkau2012-12-141-0/+16
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libubus: refactor code, move request handling to libubus-req.cFelix Fietkau2012-12-141-0/+291
Signed-off-by: Felix Fietkau <nbd@openwrt.org>