From: Josh Durgin Date: Fri, 23 Sep 2011 21:04:14 +0000 (-0700) Subject: librbd: don't zero negative lengths X-Git-Tag: v0.36~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1e4fdf510c2d891ea0a46d7c194fbc3b37c981bd;p=ceph.git librbd: don't zero negative lengths They are past the end of the buffer (and wrap around). Signed-off-by: Josh Durgin --- diff --git a/src/librbd.cc b/src/librbd.cc index e102c5e5b5f..b5ae4b18495 100644 --- a/src/librbd.cc +++ b/src/librbd.cc @@ -1377,7 +1377,7 @@ ssize_t handle_sparse_read(CephContext *cct, ldout(cct, 10) << "block_ofs=" << block_ofs << dendl; /* a hole? */ - if (extent_ofs - block_ofs > 0) { + if (extent_ofs > block_ofs) { ldout(cct, 10) << "<1>zeroing " << buf_ofs << "~" << extent_ofs << dendl; r = cb(buf_ofs, extent_ofs - block_ofs, NULL, arg); if (r < 0) { @@ -1404,7 +1404,7 @@ ssize_t handle_sparse_read(CephContext *cct, } /* last hole */ - if (buf_len - buf_ofs) { + if (buf_len > buf_ofs) { ldout(cct, 10) << "<3>zeroing " << buf_ofs << "~" << buf_len - buf_ofs << dendl; r = cb(buf_ofs, buf_len - buf_ofs, NULL, arg); if (r < 0) {