From 4c641cfc5db070b3cfb4c747a5a21068132de2f6 Mon Sep 17 00:00:00 2001 From: Enming Zhang Date: Thu, 16 Nov 2017 13:35:32 +0800 Subject: [PATCH] rgw: check read_op.read return value in RGWRados::copy_obj_data 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 --- src/rgw/rgw_rados.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 060498c60be..5d32fab16a3 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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; -- 2.39.5