From d4b22f3e17c5d23ca32012d5b67fa98d9fb1e8d1 Mon Sep 17 00:00:00 2001 From: Babu Shanmugam Date: Thu, 28 Mar 2013 10:35:01 +0530 Subject: [PATCH] rgw: more cors fixes Remove the check for read_cors_config in rgw_main.cc, and changes type of 'a' to unsigned from long as max_age cannot be a negative integer Modified the type of 'a' to unsigned long and used ULONG_MAX and strtol in rgw_cors_swift.h Signed-off-by: Babu Shanmugam --- src/rgw/rgw_cors_swift.h | 7 ++++--- src/rgw/rgw_main.cc | 7 ++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/rgw/rgw_cors_swift.h b/src/rgw/rgw_cors_swift.h index dcce4830d02dc..2b10681d7681d 100644 --- a/src/rgw/rgw_cors_swift.h +++ b/src/rgw/rgw_cors_swift.h @@ -35,7 +35,7 @@ class RGWCORSConfiguration_SWIFT : public RGWCORSConfiguration const char *expose_headers, const char *max_age) { set o, h, oc; list e; - long a = CORS_MAX_AGE_INVALID; + unsigned a = CORS_MAX_AGE_INVALID; uint8_t flags = RGW_CORS_ALL; string ao = allow_origins; @@ -58,14 +58,15 @@ class RGWCORSConfiguration_SWIFT : public RGWCORSConfiguration return -EINVAL; } } + if (expose_headers) { string eh = expose_headers; get_str_list(eh, e); } if (max_age) { char *end = NULL; - a = strtol(max_age, &end, 10); - if (a == LONG_MAX) + a = strtoul(max_age, &end, 10); + if (a == ULONG_MAX) a = CORS_MAX_AGE_INVALID; } diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index cadc51e7b3f1c..b99bdf9890ea3 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -330,12 +330,9 @@ void RGWProcess::handle_request(RGWRequest *req) abort_early(s, ret); goto done; } + req->log(s, "reading the cors attr"); - ret = handler->read_cors_config(); - if (ret < 0) { - abort_early(s, ret); - goto done; - } + handler->read_cors_config(); req->log(s, "verifying op permissions"); ret = op->verify_permission(); -- 2.39.5