]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os: put a guard when read the entire object
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 5 Jan 2016 08:10:07 +0000 (16:10 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 5 Jan 2016 08:33:15 +0000 (16:33 +0800)
Otherwise the read operation may overflow.

Fixes: #14229
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/memstore/MemStore.cc

index 0733dcc987b6beaa628771b1c61a08aa9c2af892..de00e63ae827841f79f7d0571bf5b305b9709d79 100644 (file)
@@ -307,7 +307,7 @@ int MemStore::read(
   if (offset >= o->get_size())
     return 0;
   size_t l = len;
-  if (l == 0)  // note: len == 0 means read the entire object
+  if (l == 0 && offset == 0)  // note: len == 0 means read the entire object
     l = o->get_size();
   else if (offset + l > o->get_size())
     l = o->get_size() - offset;