]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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)
committerNathan Cutler <ncutler@suse.com>
Wed, 24 Jul 2019 14:29:09 +0000 (16:29 +0200)
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>
(cherry picked from commit c6c4c5639ea34c49329719c2725886e740acd0b3)

src/rgw/rgw_rados.cc

index 3ca45acacd58fd20b5fda85700d58caf1fcdfa62..a41715f271d192f5ceca10d8ce0d2d4505e4c235 100644 (file)
@@ -8073,6 +8073,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
 
   string etag;
   real_time set_mtime;
+  uint64_t expected_size = 0;
 
   RGWObjState *dest_state = NULL;
 
@@ -8107,7 +8108,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;
   }
@@ -8115,6 +8117,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;