]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix issues with 'enforce bounds' patch
authorJoao Eduardo Luis <joao@suse.de>
Thu, 29 Nov 2018 01:05:31 +0000 (01:05 +0000)
committerJoao Eduardo Luis <joao@suse.de>
Thu, 29 Nov 2018 01:05:31 +0000 (01:05 +0000)
The patch to enforce bounds on max-keys/max-uploads/max-parts had a few
issues that would prevent us from compiling it. Instead of changing the
code provided by the submitter, we're addressing them in a separate
commit to maintain the DCO.

Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/common/options.cc
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest.cc

index cc98027cc5d7da934b6ea7fa7355842175a27028..03db62f133decb4f5c174249b20095f287ac2634 100644 (file)
@@ -6460,7 +6460,7 @@ std::vector<Option> get_rgw_options() {
     .set_default(1000)
     .set_min_max(1, 100000)
     .add_service("rgw")
-    .set_description("Upper bound on results in listing operations, ListBucket max-keys"),
+    .set_description("Upper bound on results in listing operations, ListBucket max-keys")
     .set_long_description("This caps the maximum permitted value for listing-like operations in RGW S3. "
                          "Affects ListBucket(max-keys), "
                          "ListBucketVersions(max-keys), "
index ba60ae33bcae4f000cde1c04ccb1a1a5f05d5650..eaee9cec0e9f518e13b49bb478f8b82b88226191 100644 (file)
@@ -2462,7 +2462,9 @@ int RGWListBucket::parse_max_keys()
   // Bound min value of max-keys to '0'
   // Some S3 clients explicitly send max-keys=0 to detect if the bucket is
   // empty without listing any items.
-  op_ret = parse_value_and_bound(max_keys, &max, 0, g_conf()->rgw_max_listing_results, default_max);
+  return parse_value_and_bound(max_keys, max, 0,
+                       g_conf().get_val<uint64_t>("rgw_max_listing_results"),
+                       default_max);
 }
 
 void RGWListBucket::pre_exec()
index 23046e2323b11c2da056cbd2d084cc3ce5a75853..b1e42f1b9aa447d9233b830aaa305801563f19ed 100644 (file)
@@ -2148,11 +2148,16 @@ public:
   const char* name() const override { return "get_cluster_stat"; }
 };
 
-static inline int parse_value_and_bound(const string &input, long *output, const long lower_bound, const long upper_bound, const long default_val)
+static inline int parse_value_and_bound(
+    const string &input,
+    int &output,
+    const long lower_bound,
+    const long upper_bound,
+    const long default_val)
 {
   if (!input.empty()) {
     char *endptr;
-    *output = strtol(input.c_str(), &endptr, 10);
+    output = strtol(input.c_str(), &endptr, 10);
     if (endptr) {
       if (endptr == input.c_str()) return -EINVAL;
       while (*endptr && isspace(*endptr)) // ignore white space
@@ -2161,14 +2166,14 @@ static inline int parse_value_and_bound(const string &input, long *output, const
         return -EINVAL;
       }
     }
-    if(*output > upper_bound) {
-      *output = upper_bound;
+    if(output > upper_bound) {
+      output = upper_bound;
     }
-    if(*output < lower_bound) {
-      *output = lower_bound;
+    if(output < lower_bound) {
+      output = lower_bound;
     }
   } else {
-    *output = default_val;
+    output = default_val;
   }
 
   return 0;
index 3fef3ffd05a41ab8d8a343ee6796754e938caa9c..862a8ce7457a0da90b617dadb531b0d86f0589ed 100644 (file)
@@ -1578,7 +1578,9 @@ int RGWListMultipart_ObjStore::get_params()
   }
   
   string str = s->info.args.get("max-parts");
-  op_ret = parse_value_and_bound(str, &max_parts, 0, g_conf()->rgw_max_listing_results, max_parts);
+  op_ret = parse_value_and_bound(str, max_parts, 0,
+                       g_conf().get_val<uint64_t>("rgw_max_listing_results"),
+                       max_parts);
 
   return op_ret;
 }
@@ -1588,7 +1590,9 @@ int RGWListBucketMultiparts_ObjStore::get_params()
   delimiter = s->info.args.get("delimiter");
   prefix = s->info.args.get("prefix");
   string str = s->info.args.get("max-uploads");
-  op_ret = parse_value_and_bound(str, &max_uploads, 0, g_conf()->rgw_max_listing_results, default_max);
+  op_ret = parse_value_and_bound(str, max_uploads, 0,
+                       g_conf().get_val<uint64_t>("rgw_max_listing_results"),
+                       default_max);
   if (op_ret < 0) {
     return op_ret;
   }