]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore: add sanity check for stat() syscall 8596/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 14 Apr 2016 08:43:22 +0000 (16:43 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Thu, 14 Apr 2016 14:40:08 +0000 (22:40 +0800)
The syscall stat() may fail here, the hardlink output shall
be assigned a rubbish value as a result and mislead caller.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/filestore/LFNIndex.cc

index 1994d5ac1ee92935914d842b7fc7d7cb848ca595..e22ff58e8c5ce9b4e8670da374f355875e6f5065 100644 (file)
@@ -786,6 +786,12 @@ int LFNIndex::lfn_get_name(const vector<string> &path,
       if (hardlink) {
        struct stat st;
        r = ::stat(candidate_path.c_str(), &st);
+        if (r < 0) {
+          if (errno == ENOENT)
+            *hardlink = 0;
+          else
+            return -errno;
+        }
        *hardlink = st.st_nlink;
       }
       return 0;