fix
authorMiklos Szeredi <miklos@szeredi.hu>
Tue, 14 Sep 2004 07:13:45 +0000 (07:13 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Tue, 14 Sep 2004 07:13:45 +0000 (07:13 +0000)
ChangeLog
lib/fuse.c

index 8f083f5ec8e9ecb3ced5becb4aa64431180f825e..963df1455757fbdb8f30458ff5cea8f40fec48e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-14  Miklos Szeredi <miklos@szeredi.hu>
+
+       * Check temporary file creation failure in do_getdir().  Bug
+       spotted by Terje Oseberg
+       
 2004-09-13  Miklos Szeredi <miklos@szeredi.hu>
 
        * Allow "large_read" option for 2.6 kernels but warn of deprecation
index 6c998c36a715139ce6cbe8874c077925118b11cb..659643b7210e7cddcb5ba81a1d4215dc68018053 100644 (file)
@@ -761,20 +761,27 @@ static void do_getdir(struct fuse *f, struct fuse_in_header *in)
     dh.fuse = f;
     dh.fp = tmpfile();
     dh.dir = in->ino;
-    res = -ENOENT;
-    path = get_path(f, in->ino);
-    if (path != NULL) {
-        res = -ENOSYS;
-        if (f->op.getdir)
-            res = f->op.getdir(path, &dh, (fuse_dirfil_t) fill_dir);
-        free(path);
-    }
-    fflush(dh.fp);
 
+    res = -EIO;
+    if (dh.fp == NULL)
+        perror("fuse: failed to create temporary file");
+    else {
+        res = -ENOENT;
+        path = get_path(f, in->ino);
+        if (path != NULL) {
+            res = -ENOSYS;
+            if (f->op.getdir)
+                res = f->op.getdir(path, &dh, (fuse_dirfil_t) fill_dir);
+            free(path);
+        }
+        fflush(dh.fp);
+    }
     memset(&arg, 0, sizeof(struct fuse_getdir_out));
-    arg.fd = fileno(dh.fp);
+    if (res == 0)
+        arg.fd = fileno(dh.fp);
     send_reply(f, in, res, &arg, sizeof(arg));
-    fclose(dh.fp);
+    if (dh.fp != NULL)
+        fclose(dh.fp);
 }
 
 static void do_mknod(struct fuse *f, struct fuse_in_header *in,