Explorar o código

[LibOS] Fix O_CREAT|O_EXCL flags checks in open()

borysp %!s(int64=6) %!d(string=hai) anos
pai
achega
39a58957e2
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      LibOS/shim/src/fs/shim_namei.c

+ 5 - 2
LibOS/shim/src/fs/shim_namei.c

@@ -551,10 +551,13 @@ int open_namei (struct shim_handle * hdl, struct shim_dentry * start,
 
         // Set err back to zero and fall through
         err = 0;
-    } else if (err == 0 && (flags & (O_CREAT|O_EXCL))) {
+    } else if (err == 0 && ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))) {
         err = -EEXIST;
-    } else if (err < 0)
+    }
+
+    if (err < 0) {
         goto out;
+    }
 
     // Check permission, but only if we didn't create the file.
     // creat/O_CREAT have idiosyncratic semantics about opening a