passthrough_ll: initialize unused memory
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 15 Aug 2018 08:36:31 +0000 (10:36 +0200)
committerNikolaus Rath <Nikolaus@rath.org>
Wed, 10 Oct 2018 09:49:48 +0000 (10:49 +0100)
For '.' and '..' entries only the file type in e.attr.st_mode and the inode
number in e.attr.st_ino are used.  But it's prudent to at least initialize
the other fields of struct fuse_entry_param as well, instead of using
random values from the stack.

example/passthrough_ll.c

index 80194f059a82814402f4717d5e1fdf1b29b622df..db4a3f3a49f9547576d91bf25c98fceff57edb12 100644 (file)
@@ -702,9 +702,10 @@ static void lo_do_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
                        struct fuse_entry_param e;
 
                        if (is_dot_or_dotdot(name)) {
-                               e.ino = 0;
-                               e.attr.st_ino = d->entry->d_ino;
-                               e.attr.st_mode = d->entry->d_type << 12;
+                               e = (struct fuse_entry_param) {
+                                       .attr.st_ino = d->entry->d_ino,
+                                       .attr.st_mode = d->entry->d_type << 12,
+                               };
                        } else {
                                err = lo_do_lookup(req, ino, name, &e);
                                if (err)