]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: handle zero and invalid max_keys
authorYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 12 Aug 2011 20:21:47 +0000 (13:21 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 15 Aug 2011 21:15:35 +0000 (14:15 -0700)
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rest_s3.cc

index 3c3c6e57130e9ef1ce0bf255d48a23d9a8768fc4..c0fd7214a51bf4fa1ed8acab4c850b3033bd8b78 100644 (file)
@@ -379,7 +379,17 @@ void RGWListBucket::execute()
   marker = s->args.get("marker");
   max_keys = s->args.get(limit_opt_name);
   if (!max_keys.empty()) {
-    max = atoi(max_keys.c_str());
+    const char *srcptr = max_keys.c_str();
+    char *endptr;
+    max = strtol(max_keys.c_str(), &endptr, 10);
+    if (endptr) {
+      while (*endptr && isspace(*endptr)) // ignore white space
+        endptr++;
+      if (*endptr) {
+        ret = -EINVAL;
+        goto done;
+      }
+    }
   } else {
     max = default_max;
   }
index c0fed5833b6ee1d1423b86cbba12ceb77ac9c929..1d8f7fe6866c294bb64d0693f094440202fd91cf 100644 (file)
@@ -237,7 +237,7 @@ int RGWRados::list_objects(string& id, string& bucket, int max, string& prefix,
 
   result.clear();
   int i;
-  for (i=0; i<max && p != dir_map.end(); i++, ++p) {
+  for (i=0; (!max || i<max) && p != dir_map.end(); i++, ++p) {
     RGWObjEnt obj;
     string name = p->first;
     string key = p->second;
index cbce411c4efe0d8cbe4a13425133a73875159223..cedeaa415a093c74cb908b8932864dd56dce9159 100644 (file)
@@ -131,9 +131,7 @@ void RGWListBucket_REST_S3::send_response()
     s->formatter->dump_format("Prefix", prefix.c_str());
   if (!marker.empty())
     s->formatter->dump_format("Marker", marker.c_str());
-  if (!max_keys.empty()) {
-    s->formatter->dump_format("MaxKeys", max_keys.c_str());
-  }
+  s->formatter->dump_int("MaxKeys", max);
   if (!delimiter.empty())
     s->formatter->dump_format("Delimiter", delimiter.c_str());