From: qiankunzheng Date: Fri, 25 Sep 2015 05:47:28 +0000 (-0400) Subject: rgw/rgw_admin: Checking the legality of the params X-Git-Tag: v10.0.0~41^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e7f277b86720df5b2d2fa8e80ab8d58b273f194b;p=ceph.git rgw/rgw_admin: Checking the legality of the params There is no messages When some params are invalid. so the Program should be added the function which checks params, if the params are invalid, the program will give some messages. Fixes: #13018 Signed-off-by: Qiankun Zheng --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 1140cbdbbc5f..8b2ca4e4b1b0 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1229,9 +1229,17 @@ int main(int argc, char **argv) } else if (ceph_argparse_witharg(args, i, &val, "--min-rewrite-stripe-size", (char*)NULL)) { min_rewrite_stripe_size = (uint64_t)atoll(val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--max-buckets", (char*)NULL)) { - max_buckets = atoi(val.c_str()); + max_buckets = (int)strict_strtol(val.c_str(), 10, &err); + if (!err.empty()) { + cerr << "ERROR: failed to parse max buckets: " << err << std::endl; + return EINVAL; + } } else if (ceph_argparse_witharg(args, i, &val, "--max-entries", (char*)NULL)) { - max_entries = atoi(val.c_str()); + max_entries = (int)strict_strtol(val.c_str(), 10, &err); + if (!err.empty()) { + cerr << "ERROR: failed to parse max entries: " << err << std::endl; + return EINVAL; + } } else if (ceph_argparse_witharg(args, i, &val, "--max-size", (char*)NULL)) { max_size = (int64_t)strict_strtoll(val.c_str(), 10, &err); if (!err.empty()) { @@ -1255,13 +1263,29 @@ int main(int argc, char **argv) } else if (ceph_argparse_witharg(args, i, &val, "--end-date", "--end-time", (char*)NULL)) { end_date = val; } else if (ceph_argparse_witharg(args, i, &val, "--num-shards", (char*)NULL)) { - num_shards = atoi(val.c_str()); + num_shards = (int)strict_strtol(val.c_str(), 10, &err); + if (!err.empty()) { + cerr << "ERROR: failed to parse num shards: " << err << std::endl; + return EINVAL; + } } else if (ceph_argparse_witharg(args, i, &val, "--max-concurrent-ios", (char*)NULL)) { - max_concurrent_ios = atoi(val.c_str()); + max_concurrent_ios = (int)strict_strtol(val.c_str(), 10, &err); + if (!err.empty()) { + cerr << "ERROR: failed to parse max concurrent ios: " << err << std::endl; + return EINVAL; + } } else if (ceph_argparse_witharg(args, i, &val, "--orphan-stale-secs", (char*)NULL)) { - orphan_stale_secs = (uint64_t)atoi(val.c_str()); + orphan_stale_secs = (uint64_t)strict_strtoll(val.c_str(), 10, &err); + if (!err.empty()) { + cerr << "ERROR: failed to parse orphan stale secs: " << err << std::endl; + return EINVAL; + } } else if (ceph_argparse_witharg(args, i, &val, "--shard-id", (char*)NULL)) { - shard_id = atoi(val.c_str()); + shard_id = (int)strict_strtol(val.c_str(), 10, &err); + if (!err.empty()) { + cerr << "ERROR: failed to parse shard id: " << err << std::endl; + return EINVAL; + } specified_shard_id = true; } else if (ceph_argparse_witharg(args, i, &val, "--daemon-id", (char*)NULL)) { daemon_id = val;