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

index 0c559633878b04c8b62bab1fe6b7ece8bc834852..a30ec88dd5f43d3e1ff12e9e7e1f8e0ac4510475 100644 (file)
@@ -2325,6 +2325,11 @@ void Server::handle_client_open(MDRequest *mdr)
   bool need_auth = !file_mode_is_readonly(cmode) || (flags & O_TRUNC);
 
   dout(7) << "open on " << req->get_filepath() << dendl;
+
+  if (cmode < 0) {
+    reply_request(mdr, -EINVAL);
+    return;
+  }
   
   set<SimpleLock*> rdlocks, wrlocks, xlocks;
   CInode *cur = rdlock_path_pin_ref(mdr, 0, rdlocks, need_auth);
@@ -2489,6 +2494,12 @@ void Server::handle_client_openc(MDRequest *mdr)
 
   dout(7) << "open w/ O_CREAT on " << req->get_filepath() << dendl;
 
+  int cmode = ceph_flags_to_mode(req->head.args.open.flags);
+  if (cmode < 0) {
+    reply_request(mdr, -EINVAL);
+    return;
+  }
+
   bool excl = (req->head.args.open.flags & O_EXCL);
   set<SimpleLock*> rdlocks, wrlocks, xlocks;
   ceph_file_layout *dir_layout = NULL;
@@ -2541,10 +2552,7 @@ void Server::handle_client_openc(MDRequest *mdr)
     return;
   }
 
-  
-
   // created null dn.
-
     
   // create inode.
   mdr->now = ceph_clock_now(g_ceph_context);
@@ -2552,8 +2560,6 @@ void Server::handle_client_openc(MDRequest *mdr)
   SnapRealm *realm = diri->find_snaprealm();   // use directory's realm; inode isn't attached yet.
   snapid_t follows = realm->get_newest_seq();
 
-  int cmode = ceph_flags_to_mode(req->head.args.open.flags);
-
   CInode *in = prepare_new_inode(mdr, dn->get_dir(), inodeno_t(req->head.ino),
                                 req->head.args.open.mode | S_IFREG, &layout);
   assert(in);