From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 05:04:37 +0000 (+0100) Subject: rgw/rgw_op.cc: fix potential null-deref in strcmp() X-Git-Tag: v9.0.0~186^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=de7bcfd8d0e578207cbd9237bc166937fdadcd62;p=ceph.git rgw/rgw_op.cc: fix potential null-deref in strcmp() Signed-off-by: Danny Al-Gaaf --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index f3a3622023a..dc12a880ca9 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -523,6 +523,12 @@ int RGWOp::init_quota() static bool validate_cors_rule_method(RGWCORSRule *rule, const char *req_meth) { uint8_t flags = 0; + + if (!req_meth) { + dout(5) << "req_meth is null" << dendl; + return false; + } + if (strcmp(req_meth, "GET") == 0) flags = RGW_CORS_GET; else if (strcmp(req_meth, "POST") == 0) flags = RGW_CORS_POST; else if (strcmp(req_meth, "PUT") == 0) flags = RGW_CORS_PUT; @@ -628,11 +634,12 @@ bool RGWOp::generate_cors_headers(string& origin, string& method, string& header req_meth = s->info.method; } - if (req_meth) + if (req_meth) { method = req_meth; - /* CORS 6.2.5. */ - if (!validate_cors_rule_method(rule, req_meth)) { - return false; + /* CORS 6.2.5. */ + if (!validate_cors_rule_method(rule, req_meth)) { + return false; + } } /* CORS 6.2.4. */