From e0267cd31b0ed2cfcb80a038ee05962a4becd625 Mon Sep 17 00:00:00 2001 From: zhang Shaowen Date: Mon, 23 Dec 2019 10:13:32 +0800 Subject: [PATCH] rgw: using strict_strtoll for append position. If not, any invalid value will be decoded as zero which is not correct. Signed-off-by: zhang Shaowen --- src/rgw/rgw_rest_s3.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index c021ae0cbba6..64df3022c6ac 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -1858,10 +1858,11 @@ 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; + position = (uint64_t)strict_strtoll(pos_str.c_str(), 10, &err); + if (!err.empty()) { + ldpp_dout(s, 10) << "bad position: " << pos_str << ": " << err << dendl; return -EINVAL; - } else { - position = strtoull(pos_str.c_str(), NULL, 10); } } -- 2.47.3