]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
FileJournal: check return value of lseek in write_fd
authorSamuel Just <sam.just@inktank.com>
Tue, 25 Sep 2012 21:19:49 +0000 (14:19 -0700)
committerSamuel Just <sam.just@inktank.com>
Wed, 26 Sep 2012 17:15:07 +0000 (10:15 -0700)
CID 716859: Other violation (CHECKED_RETURN)At (1): Calling function
"lseek64(this->fd, pos, 0)" without checking return value. This library
function may fail and return an error code.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/os/FileJournal.cc

index eec5c9d320c2cf3c24195968dad7e159b2614c60..d1c92dc0937a253e9bf3a6558a574acd49d7fd28 100644 (file)
@@ -946,8 +946,13 @@ int FileJournal::write_bl(off64_t& pos, bufferlist& bl)
 {
   align_bl(pos, bl);
 
-  ::lseek64(fd, pos, SEEK_SET);
-  int ret = bl.write_fd(fd);
+  int ret = ::lseek64(fd, pos, SEEK_SET);
+  if (ret) {
+    ret = -errno;
+    derr << "FileJournal::write_bl : lseek64 failed " << cpp_strerror(ret) << dendl;
+    return ret;
+  }
+  ret = bl.write_fd(fd);
   if (ret) {
     derr << "FileJournal::write_bl : write_fd failed: " << cpp_strerror(ret) << dendl;
     return ret;