summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens2026-05-31 15:38:38 +0000
committerHauke Mehrtens2026-06-03 23:20:02 +0000
commitd06d2a81dc29d746c5f13a9cc07ce779b5ed39be (patch)
tree3a384d7f7fb14313e1d496aa230da6b25c5f20c2
parentaf5d6f431186bcd1847e9d3210652b09dbc90ce5 (diff)
downloadrpcd-d06d2a81dc29d746c5f13a9cc07ce779b5ed39be.tar.gz
rc: fix memory leak of list request context
rc_list() allocates a struct rc_list_context with calloc() and defers the request; rc_list_readdir() walks /etc/init.d asynchronously and, once the directory is exhausted (or the requested entry was found), sends the reply and completes the deferred request -- but never frees the context. free(c) only existed in the early opendir() failure path, so every successful "rc list" ubus call leaked the context (which embeds a PATH_MAX sized path buffer), slowly exhausting memory. Free the context in the terminal path after completing the request. Assisted-by: Claude:claude-opus-4-8 Link: https://github.com/openwrt/rpcd/pull/34 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--rc.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/rc.c b/rc.c
index 3d192f1..ae54a10 100644
--- a/rc.c
+++ b/rc.c
@@ -193,6 +193,7 @@ static void rc_list_readdir(struct rc_list_context *c)
closedir(c->dir);
ubus_send_reply(c->ctx, &c->req, c->buf->head);
ubus_complete_deferred_request(c->ctx, &c->req, UBUS_STATUS_OK);
+ free(c);
return;
}