]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Add is_dir check before changing directory 32637/head
authorVarsha Rao <varao@redhat.com>
Tue, 14 Jan 2020 16:07:09 +0000 (21:37 +0530)
committerVarsha Rao <varao@redhat.com>
Tue, 14 Jan 2020 16:12:26 +0000 (21:42 +0530)
Fixes: https://tracker.ceph.com/issues/43440
Signed-off-by: Varsha Rao <varao@redhat.com>
src/client/Client.cc

index 06d71d3537a6f4d4bfae22f6662622e85aa791df..ce99f0ef4ee98b74dc374720ef7bbc85367c927d 100644 (file)
@@ -9900,6 +9900,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;