From: J. Eric Ivancich Date: Wed, 4 Nov 2020 15:03:51 +0000 (-0500) Subject: Merge pull request #32394 from zhangsw/fix-appendobj-invalidposition X-Git-Tag: v16.1.0~690 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4ee736e57abce316cbe0ecf6c1f4e472ef069a41;p=ceph.git Merge pull request #32394 from zhangsw/fix-appendobj-invalidposition 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 --- 4ee736e57abce316cbe0ecf6c1f4e472ef069a41 diff --cc src/rgw/rgw_rest_s3.cc index bb856aa8504b,8674109f0040..eb50d643577b --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@@ -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(); }