]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: check read_op.read return value in RGWRados::copy_obj_data
authorEnming Zhang <enming.zhang@umcloud.com>
Thu, 16 Nov 2017 05:35:32 +0000 (13:35 +0800)
committerEnming Zhang <enming.zhang@umcloud.com>
Thu, 16 Nov 2017 05:35:32 +0000 (13:35 +0800)
The return-value-type of RGWRados::Object::Read::read is int, and
the return value of RGWRados::Object::Read::read is either the
length of object data which has been read if everything is OK,
or the error value which is negative value if something is wrong.

If an negative error value is assigned to read_len which is an
unsigned long long type, the read_len will be a very large value,
which will cause an error during RGWPutObjProcessor processing.

Signed-off-by: Enming Zhang <enming.zhang@umcloud.com>
src/rgw/rgw_rados.cc

index 060498c60be6dba73cd2cd36ac7cbf01c79a35ab..5d32fab16a313ea387d5af89aa8a693de01b4052 100644 (file)
@@ -8229,6 +8229,10 @@ int RGWRados::copy_obj_data(RGWObjectCtx& obj_ctx,
   do {
     bufferlist bl;
     ret = read_op.read(ofs, end, bl);
+    if (ret < 0) {
+      ldout(cct, 0) << "ERROR: fail to read object data, ret = " << ret << dendl;
+      return ret;
+    }
 
     uint64_t read_len = ret;
     bool again;