uxc: fix segfault caused by use-after-free
authorDaniel Golle <daniel@makrotopia.org>
Mon, 4 Oct 2021 00:31:39 +0000 (01:31 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 12 Oct 2021 23:35:13 +0000 (00:35 +0100)
Don't free blob_buf which was sent via ubus.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
uxc.c

diff --git a/uxc.c b/uxc.c
index f67271e925b78b5957e1fbc03ac07aea22b7f24d..a896d5ff148b6a8c1d4a43b0e751764452dec4ba 100644 (file)
--- a/uxc.c
+++ b/uxc.c
@@ -586,12 +586,12 @@ static int uxc_create(char *name, bool immediately)
        ret = 0;
        if (ubus_lookup_id(ctx, "container", &id) ||
                ubus_invoke(ctx, id, "add", req.head, NULL, NULL, 3000)) {
+               blob_buf_free(&req);
                ret = EIO;
        }
 
        free(jailname);
        free(path);
-       blob_buf_free(&req);
 
        return ret;
 }