From: zhangshaowen Date: Mon, 20 Apr 2020 02:24:14 +0000 (+0800) Subject: rgw: negative position is not allowed. X-Git-Tag: v16.1.0~690^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6ad21d3683492ac70edbedcb7f1df362966d50be;p=ceph.git rgw: negative position is not allowed. Signed-off-by: zhangshaowen --- diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 64df3022c6ac..8674109f0040 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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();