From: Felix Fietkau Date: Thu, 2 Jan 2025 11:06:53 +0000 (+0100) Subject: libubus: close file descriptor after sending it from a request X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d996988ae55b6af12e4611fdd758a2f0ad27a9a1;p=project%2Fubus.git libubus: close file descriptor after sending it from a request Avoids local file descriptor leaks Signed-off-by: Felix Fietkau --- diff --git a/libubus-req.c b/libubus-req.c index ae9d192..474aac2 100644 --- a/libubus-req.c +++ b/libubus-req.c @@ -192,6 +192,8 @@ void ubus_complete_deferred_request(struct ubus_context *ctx, struct ubus_reques blob_put_int32(&b, UBUS_ATTR_STATUS, ret); blob_put_int32(&b, UBUS_ATTR_OBJID, req->object); ubus_send_msg(ctx, req->seq, b.head, UBUS_MSG_STATUS, req->peer, req->fd); + if (req->fd >= 0) + close(req->fd); } static void ubus_put_data(struct blob_buf *buf, struct blob_attr *msg)