From: Gui Hecheng Date: Fri, 10 Mar 2017 08:47:39 +0000 (+0800) Subject: rgw_rest_s3: unify return value type of valid_s3_bucket/object_name X-Git-Tag: v12.0.2~271^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b4879c9efbcaaa9324844c226c0aad81489d838c;p=ceph.git rgw_rest_s3: unify return value type of valid_s3_bucket/object_name Signed-off-by: Gui Hecheng --- diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index d5d1626f3d10..829232791969 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -1522,8 +1522,9 @@ public: RGWOp::init(rados_ctx->store, get_state(), this); op = this; // assign self as op: REQUIRED - if (! valid_s3_object_name(obj_name)) - return -ERR_INVALID_OBJECT_NAME; + int rc = valid_s3_object_name(obj_name); + if (rc != 0) + return rc; return 0; } @@ -2169,8 +2170,9 @@ public: dest_object = dst_parent->format_child_name(dst_name); // need s->object_name? - if (! valid_s3_object_name(dest_object)) - return -ERR_INVALID_OBJECT_NAME; + int rc = valid_s3_object_name(dest_object); + if (rc != 0) + return rc; /* XXX and fixup key attr (could optimize w/string ref and * dest_object) */ diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index a5a17686dd8a..e0726733684e 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -610,14 +610,14 @@ static inline bool looks_like_ip_address(const char *bucket) return (num_periods == 3); } -static inline bool valid_s3_object_name(const string& name) { +static inline int valid_s3_object_name(const string& name) { if (name.size() > 1024) { - return false; + return -ERR_INVALID_OBJECT_NAME; } if (check_utf8(name.c_str(), name.size())) { - return false; + return -ERR_INVALID_OBJECT_NAME; } - return true; + return 0; } static inline int valid_s3_bucket_name(const string& name, bool relaxed=false)