examples/passthrough_ll.c: Fix segfault when showing help or version.
authorPrzemyslaw Pawelczyk <przemoc@gmail.com>
Mon, 28 Nov 2016 13:41:37 +0000 (14:41 +0100)
committerNikolaus Rath <Nikolaus@rath.org>
Tue, 29 Nov 2016 05:35:05 +0000 (21:35 -0800)
root lo_inode's next and prev were not set early enough, which led to
accessing addr 0x8 (or 0x4, depending on ptr size) when setting prev
variable in lo_free(lo.root.next), because lo.root.next was NULL.

example/passthrough_ll.c

index 995026ea2b4d2bde3c037ac7efdbe2f63fe8bb95..9c6144a88c1165c492fa9a91dc165919d0402968 100644 (file)
@@ -463,6 +463,8 @@ int main(int argc, char *argv[])
        struct lo_data lo = { .debug = 0 };
        int ret = -1;
 
+       lo.root.next = lo.root.prev = &lo.root;
+
        if (fuse_parse_cmdline(&args, &opts) != 0)
                return 1;
        if (opts.show_help) {
@@ -479,7 +481,6 @@ int main(int argc, char *argv[])
        }
 
        lo.debug = opts.debug;
-       lo.root.next = lo.root.prev = &lo.root;
        lo.root.fd = open("/", O_PATH);
        lo.root.nlookup = 2;
        if (lo.root.fd == -1)