diff options
| author | Tito Brasolin | 2025-09-05 08:09:16 +0000 |
|---|---|---|
| committer | Robert Marko | 2025-12-24 10:08:44 +0000 |
| commit | 506e24987b97fbc866005bfb71316bd63601a1ef (patch) | |
| tree | 45dc91c7f8e6d18b3ccb9202d9f1f3052fa21ec3 | |
| parent | ebb92e6b339b88bbc6b76501b6603c52d4887ba1 (diff) | |
| download | uhttpd-master.tar.gz | |
Fixes a potential SIGSEGV when a client disconnects from a /ubus/subscribe/... endpoint without unsubscribing.
The ubus subscriber is now properly unregistered in a cleanup handler, preventing callbacks on freed client structures.
Fixes: #1
Signed-off-by: Tito Brasolin <tito.brasolin@kerberos.energy>
Link: https://github.com/openwrt/uhttpd/pull/18
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
| -rw-r--r-- | ubus.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -362,6 +362,14 @@ static void uh_ubus_subscription_notification_remove_cb(struct ubus_context *ctx ops->request_done(cl); } +/* Cleanup function to unregister ubus subscriber when HTTP client closes */ +static void uh_ubus_subscription_free(struct client *cl) +{ + struct dispatch_ubus *du = &cl->dispatch.ubus; + if (du->sub.obj.id) + ubus_unregister_subscriber(ctx, &du->sub); +} + static void uh_ubus_handle_get_subscribe(struct client *cl, const char *path) { struct dispatch_ubus *du = &cl->dispatch.ubus; @@ -399,6 +407,9 @@ static void uh_ubus_handle_get_subscribe(struct client *cl, const char *path) if (conf.events_retry) ops->chunk_printf(cl, "retry: %d\n", conf.events_retry); + /* Ensure cleanup on client disconnect */ + cl->dispatch.free = uh_ubus_subscription_free; + return; err_unregister: |