]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: fetch_remote_obj() compares expected object size
authorCasey Bodley <cbodley@redhat.com>
Wed, 29 May 2019 21:11:13 +0000 (17:11 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 29 May 2019 21:11:17 +0000 (17:11 -0400)
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 <xiaoxchen@ebay.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rados.cc

index 0a2ead992b63718b7113b7586879132d6ccb16e1..ccdc9cebb8f95326cbe6eb67e99c9f92957587e3 100644 (file)
@@ -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;