]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rgw_op.cc: fix potential null-deref in strcmp()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 5 Mar 2015 05:04:37 +0000 (06:04 +0100)
committerKefu Chai <kchai@redhat.com>
Thu, 12 Mar 2015 09:37:59 +0000 (17:37 +0800)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
(cherry picked from commit de7bcfd8d0e578207cbd9237bc166937fdadcd62)

src/rgw/rgw_op.cc

index 87710fc744ab93ef8c0d5ca8a43236b39c61af64..06c504eee65b79429ec757c527aeddd51e1c987c 100644 (file)
@@ -522,6 +522,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;
@@ -627,11 +633,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. */