diff options
| author | Felix Fietkau | 2025-01-02 11:06:53 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2025-01-02 11:24:27 +0000 |
| commit | d996988ae55b6af12e4611fdd758a2f0ad27a9a1 (patch) | |
| tree | 3cd46bfe47833477f35941c7849725d493754505 | |
| parent | 252a9b0c1774790fb9c25735d5a09c27dba895db (diff) | |
| download | ubus-d996988ae55b6af12e4611fdd758a2f0ad27a9a1.tar.gz | |
libubus: close file descriptor after sending it from a request
Avoids local file descriptor leaks
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | libubus-req.c | 2 |
1 files changed, 2 insertions, 0 deletions
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) |