]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #32394 from zhangsw/fix-appendobj-invalidposition
authorJ. Eric Ivancich <ivancich@redhat.com>
Wed, 4 Nov 2020 15:03:51 +0000 (10:03 -0500)
committerGitHub <noreply@github.com>
Wed, 4 Nov 2020 15:03:51 +0000 (10:03 -0500)
rgw: using strict_strtoll for append position. If not, any invalid value will be decoded as zero which is not correct.

Reviewed-by: Yuval Lifshitz <ylifshit@redhat.com>
1  2 
src/rgw/rgw_rest_s3.cc

index bb856aa8504bd218439a9d24f39d40fd35d910be,8674109f00402d965b6c94ad0f90ea967452f859..eb50d643577b8e2f1513250b005d01dbb00850b9
@@@ -2426,13 -1858,18 +2426,18 @@@ int RGWPutObj_ObjStore_S3::get_params(
    append = s->info.args.exists("append");
    if (append) {
      string pos_str = s->info.args.get("position");
-     if (pos_str.empty()) {
+     string 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;
-     } else {
-       position = strtoull(pos_str.c_str(), NULL, 10);
      }
+     position = uint64_t(pos_tmp);
    }
 -  
 +
    return RGWPutObj_ObjStore::get_params();
  }