]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: don't zero negative lengths
authorJosh Durgin <josh.durgin@dreamhost.com>
Fri, 23 Sep 2011 21:04:14 +0000 (14:04 -0700)
committerJosh Durgin <josh.durgin@dreamhost.com>
Tue, 27 Sep 2011 01:10:40 +0000 (18:10 -0700)
They are past the end of the buffer (and wrap around).

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
src/librbd.cc

index 8dc843d8a75a8cb8099b870a67e69f5eaa985dfb..0192521aae75d677a3671055b813fbe2c733fdb1 100644 (file)
@@ -1371,7 +1371,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) {
@@ -1398,7 +1398,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) {