]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: check for invalid file mode
authorSage Weil <sage@newdream.net>
Tue, 19 Jul 2011 17:38:40 +0000 (10:38 -0700)
committerSage Weil <sage@newdream.net>
Tue, 19 Jul 2011 18:03:22 +0000 (11:03 -0700)
Signed-off-by: Sage Weil <sage@newdream.net>
src/client/Client.cc

index e293b3f1127ced883255edff9cee46d9daa8b74c..47e7bf72b3ca25fd2bcb5b590f7c92076a5c569c 100644 (file)
@@ -4677,6 +4677,8 @@ Fh *Client::_create_fh(Inode *in, int flags, int cmode)
 int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, int uid, int gid) 
 {
   int cmode = ceph_flags_to_mode(flags);
+  if (cmode < 0)
+    return -EINVAL;
   int want = ceph_caps_for_mode(cmode);
   int result = 0;
 
@@ -6016,6 +6018,10 @@ int Client::_create(Inode *dir, const char *name, int flags, mode_t mode, Inode
   if (dir->snapid != CEPH_NOSNAP) {
     return -EROFS;
   }
+  
+  int cmode = ceph_flags_to_mode(flags);
+  if (cmode < 0)
+    return -EINVAL;
 
   MetaRequest *req = new MetaRequest(CEPH_MDS_OP_CREATE);
 
@@ -6044,7 +6050,6 @@ int Client::_create(Inode *dir, const char *name, int flags, mode_t mode, Inode
   if (res >= 0) {
     res = _lookup(dir, name, inp);
     if (res >= 0) {
-      int cmode = ceph_flags_to_mode(flags);
       (*inp)->get_open_ref(cmode);
       *fhp = _create_fh(*inp, flags, cmode);
     }