From c6c4c5639ea34c49329719c2725886e740acd0b3 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 29 May 2019 17:11:13 -0400 Subject: [PATCH] rgw: fetch_remote_obj() compares expected object size if the size of object data received doesn't match the value returned in the Rgwx-Object-Size header, fail with -EIO Fixes: https://tracker.ceph.com/issues/39992 Signed-off-by: Xiaoxi CHEN Signed-off-by: Casey Bodley --- src/rgw/rgw_rados.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 0a2ead992b6..ccdc9cebb8f 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4346,6 +4346,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, string etag; real_time set_mtime; + uint64_t expected_size = 0; RGWObjState *dest_state = NULL; @@ -4380,7 +4381,8 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, goto set_err_state; } - ret = conn->complete_request(in_stream_req, &etag, &set_mtime, nullptr, nullptr, nullptr); + ret = conn->complete_request(in_stream_req, &etag, &set_mtime, + &expected_size, nullptr, nullptr); if (ret < 0) { goto set_err_state; } @@ -4388,6 +4390,12 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, if (ret < 0) { goto set_err_state; } + if (cb.get_data_len() != expected_size) { + ret = -EIO; + ldout(cct, 0) << "ERROR: object truncated during fetching, expected " + << expected_size << " bytes but received " << cb.get_data_len() << dendl; + goto set_err_state; + } if (compressor && compressor->is_compressed()) { bufferlist tmp; RGWCompressionInfo cs_info; -- 2.39.5