]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: negative position is not allowed. 32394/head
authorzhangshaowen <zhangshaowen@cmss.chinamobile.com>
Mon, 20 Apr 2020 02:24:14 +0000 (10:24 +0800)
committerzhangshaowen <zhangshaowen@cmss.chinamobile.com>
Mon, 20 Apr 2020 02:24:14 +0000 (10:24 +0800)
Signed-off-by: zhangshaowen <zhangshaowen@cmss.chinamobile.com>
src/rgw/rgw_rest_s3.cc

index 64df3022c6ac919b0587f6d3fb09c0cab8ad13b3..8674109f00402d965b6c94ad0f90ea967452f859 100644 (file)
@@ -1859,11 +1859,15 @@ int RGWPutObj_ObjStore_S3::get_params()
   if (append) {
     string pos_str = s->info.args.get("position");
     string err;
-    position = (uint64_t)strict_strtoll(pos_str.c_str(), 10, &err);
+    long long pos_tmp = strict_strtoll(pos_str.c_str(), 10, &err);
     if (!err.empty()) {
       ldpp_dout(s, 10) << "bad position: " << pos_str << ": " << err << dendl;
       return -EINVAL;
+    } else if (pos_tmp < 0) {
+      ldpp_dout(s, 10) << "bad position: " << pos_str << ": " << "position shouldn't be negative" << dendl;
+      return -EINVAL;
     }
+    position = uint64_t(pos_tmp);
   }
   
   return RGWPutObj_ObjStore::get_params();