]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add the check for Content-Length in BulkUpload. 12243/head
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 30 Nov 2016 20:58:30 +0000 (21:58 +0100)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Sun, 2 Apr 2017 16:35:22 +0000 (18:35 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rest_swift.cc

index 72bfefb4fe81ac9f58fdab0cc12f7c55b5eadf67..9d770394fadb339128ada46bec14b7b81106fbef 100644 (file)
@@ -5928,6 +5928,10 @@ void RGWBulkUploadOp::execute()
   /* Create an instance of stream-abstracting class. Having this indirection
    * allows for easy introduction of decompressors like gzip and bzip2. */
   auto stream = create_stream();
+  if (! stream) {
+    return;
+  }
+
   auto status = rgw::tar::StatusIndicator::create();
   do {
     op_ret = stream->get_exactly(rgw::tar::BLOCK_SIZE, buffer);
index d02d4afc2925c97bf8c054d6cd10c680a7f1e05a..44aec1e73477b4126e147fc5370e7985be286d3e 100644 (file)
@@ -1430,8 +1430,8 @@ RGWBulkUploadOp_ObjStore_SWIFT::create_stream()
     req_state* const s;
 
   public:
-    SwiftStreamGetter(req_state* const s)
-      : conlen(atoll(s->length)),
+    SwiftStreamGetter(req_state* const s, const size_t conlen)
+      : conlen(conlen),
         curpos(0),
         s(s) {
     }
@@ -1477,10 +1477,16 @@ RGWBulkUploadOp_ObjStore_SWIFT::create_stream()
     }
   };
 
-  // FIXME: lack of conlen
-  ldout(s->cct, 20) << "bulk upload: create_stream for length="
-                    << s->length << dendl;
-  return std::unique_ptr<SwiftStreamGetter>(new SwiftStreamGetter(s));
+  if (! s->length) {
+    op_ret = -EINVAL;
+    return nullptr;
+  } else {
+    ldout(s->cct, 20) << "bulk upload: create_stream for length="
+                      << s->length << dendl;
+
+    const size_t conlen = atoll(s->length);
+    return std::unique_ptr<SwiftStreamGetter>(new SwiftStreamGetter(s, conlen));
+  }
 }
 
 void RGWBulkUploadOp_ObjStore_SWIFT::send_response()