summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-11-21 22:50:30 +0100
committerFelix Fietkau <nbd@openwrt.org>2013-11-21 22:50:31 +0100
commitcd66639800ee2882a0867ec54868502eb9b893d8 (patch)
treeb1fae68cc97bab2407e7b8584d39bc664a37fd92 /utils.c
parentaec143997b9aba65f7ea702d7cd42b553afe335f (diff)
uhttpd: fix crashes in the ubus plugin
The ubus plugin calls blocking ubus functions that loop back into uloop_run. Protect the client data structure with refcounting to ensure that the outer uloop_run call does not clean up the data that the inner uloop_run call is still processing. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 3b868e3..b1d7d37 100644
--- a/utils.c
+++ b/utils.c
@@ -35,6 +35,9 @@ void uh_chunk_write(struct client *cl, const void *data, int len)
{
bool chunked = uh_use_chunked(cl);
+ if (cl->state == CLIENT_STATE_CLEANUP)
+ return;
+
uloop_timeout_set(&cl->timeout, conf.network_timeout * 1000);
if (chunked)
ustream_printf(cl->us, "%X\r\n", len);
@@ -49,6 +52,9 @@ void uh_chunk_vprintf(struct client *cl, const char *format, va_list arg)
va_list arg2;
int len;
+ if (cl->state == CLIENT_STATE_CLEANUP)
+ return;
+
uloop_timeout_set(&cl->timeout, conf.network_timeout * 1000);
if (!uh_use_chunked(cl)) {
ustream_vprintf(cl->us, format, arg);
@@ -81,6 +87,9 @@ void uh_chunk_eof(struct client *cl)
if (!uh_use_chunked(cl))
return;
+ if (cl->state == CLIENT_STATE_CLEANUP)
+ return;
+
ustream_printf(cl->us, "0\r\n\r\n");
}