]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Add is_dir check before changing directory 32916/head
authorVarsha Rao <varao@redhat.com>
Tue, 14 Jan 2020 16:07:09 +0000 (21:37 +0530)
committerNathan Cutler <ncutler@suse.com>
Mon, 27 Jan 2020 16:48:32 +0000 (17:48 +0100)
Fixes: https://tracker.ceph.com/issues/43440
Signed-off-by: Varsha Rao <varao@redhat.com>
(cherry picked from commit 20fa3940bdbb1e7a9aaaa4c7f7be358f85497cb3)

src/client/Client.cc

index 8a89d086ed0258a50a1cdbfaf3db45aaa3c43308..b0899e3ef409fbda2228d9d9ef8463da053bd3bc 100644 (file)
@@ -9884,6 +9884,10 @@ int Client::chdir(const char *relpath, std::string &new_cwd,
   int r = path_walk(path, &in, perms);
   if (r < 0)
     return r;
+
+  if (!(in.get()->is_dir()))
+    return -ENOTDIR;
+
   if (cwd != in)
     cwd.swap(in);
   ldout(cct, 3) << "chdir(" << relpath << ")  cwd now " << cwd->ino << dendl;