libfuse: fix handling of '.' and '..' in highlevel readdirplus
authorMiklos Szeredi <miklos@szeredi.hu>
Thu, 26 Feb 2015 16:12:30 +0000 (17:12 +0100)
committerMiklos Szeredi <mszeredi@suse.cz>
Thu, 26 Feb 2015 16:12:30 +0000 (17:12 +0100)
ChangeLog
lib/fuse.c

index 983a7d958e020adcee5b21b1bb62e5714d2927e3..1a20560e9b687c722896222400111f94a2d01f56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@
        * libfuse: fix fuse_remove_signal_handlers() to properly restore
        the default signal handler.  Reported by: Chris Johnson
 
+       * libfuse: fix handling of '.' and '..' in highlevel readdirplus
+
 2014-07-21  Miklos Szeredi <miklos@szeredi.hu>
 
        * libfuse: highlevel API: fix directory file handle passed to
index 75d657c4aad9d7a815771af7fc5e3c75d3c19004..2f1c85ed6239da58916efcd7bed23c37699b9b68 100644 (file)
@@ -3418,6 +3418,12 @@ static int fill_dir(void *dh_, const char *name, const struct stat *statp,
        return 0;
 }
 
+static int is_dot_or_dotdot(const char *name)
+{
+       return name[0] == '.' && (name[1] == '\0' ||
+                                 (name[1] == '.' && name[2] == '\0'));
+}
+
 static int fill_dir_plus(void *dh_, const char *name, const struct stat *statp,
                         off_t off, enum fuse_fill_dir_flags flags)
 {
@@ -3437,10 +3443,12 @@ static int fill_dir_plus(void *dh_, const char *name, const struct stat *statp,
        if (off && statp && (flags & FUSE_FILL_DIR_PLUS)) {
                e.attr = *statp;
 
-               res = do_lookup(f, dh->nodeid, name, &e);
-               if (res) {
-                       dh->error = res;
-                       return 1;
+               if (!is_dot_or_dotdot(name)) {
+                       res = do_lookup(f, dh->nodeid, name, &e);
+                       if (res) {
+                               dh->error = res;
+                               return 1;
+                       }
                }
        } else {
                e.attr.st_ino = FUSE_UNKNOWN_INO;