ubus: duplicate request buffer to avoid memory corruption with multiple requests
[project/uhttpd.git] / client.c
index 7604d7e..a971b3b 100644 (file)
--- a/client.c
+++ b/client.c
@@ -110,7 +110,6 @@ void uh_request_done(struct client *cl)
 {
        uh_chunk_eof(cl);
        uh_dispatch_done(cl);
-       cl->us->notify_write = NULL;
        memset(&cl->dispatch, 0, sizeof(cl->dispatch));
 
        if (!conf.http_keepalive || cl->request.connection_close)
@@ -195,8 +194,10 @@ static bool client_init_cb(struct client *cl, char *buf, int len)
        if (!newline)
                return false;
 
-       if (newline == buf)
+       if (newline == buf) {
+               ustream_consume(cl->us, 2);
                return true;
+       }
 
        *newline = 0;
        blob_buf_init(&cl->hdr, 0);
@@ -568,6 +569,7 @@ bool uh_accept_client(int fd, bool tls)
        next_client = NULL;
        n_clients++;
        cl->id = client_id++;
+       cl->tls = tls;
 
        return true;
 }