]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: return EINVAL on invalid name from {insert,update,create_or_move}_item, set_it...
authorSage Weil <sage@inktank.com>
Mon, 15 Jul 2013 23:12:23 +0000 (16:12 -0700)
committerDan Mick <dan.mick@inktank.com>
Tue, 16 Jul 2013 22:13:55 +0000 (15:13 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h

index 1a4097c08b96ddfd4398b0e6d8b038dfa9e30f40..e96e6123aaba17c070547d72b550fd45331fcde7 100644 (file)
@@ -333,6 +333,9 @@ int CrushWrapper::insert_item(CephContext *cct, int item, float weight, string n
   ldout(cct, 5) << "insert_item item " << item << " weight " << weight
                << " name " << name << " loc " << loc << dendl;
 
+  if (!is_valid_crush_name(name))
+    return -EINVAL;
+
   if (name_exists(name)) {
     if (get_item_id(name) != item) {
       ldout(cct, 10) << "device name '" << name << "' already exists as id "
@@ -473,6 +476,10 @@ int CrushWrapper::create_or_move_item(CephContext *cct, int item, float weight,
 {
   int ret = 0;
   int old_iweight;
+
+  if (!is_valid_crush_name(name))
+    return -EINVAL;
+
   if (check_item_loc(cct, item, loc, &old_iweight)) {
     ldout(cct, 5) << "create_or_move_item " << item << " already at " << loc << dendl;
   } else {
@@ -497,6 +504,9 @@ int CrushWrapper::update_item(CephContext *cct, int item, float weight, string n
                << " name " << name << " loc " << loc << dendl;
   int ret = 0;
 
+  if (!is_valid_crush_name(name))
+    return -EINVAL;
+
   // compare quantized (fixed-point integer) weights!  
   int iweight = (int)(weight * (float)0x10000);
   int old_iweight;
index f399e342110de81ef62f50aae74d28f0d64923e3..3d07a281956ed7830931e3ad5a962cf6f83f1cd8 100644 (file)
@@ -200,10 +200,13 @@ public:
       return p->second.c_str();
     return 0;
   }
-  void set_item_name(int i, const string& name) {
+  int set_item_name(int i, const string& name) {
+    if (!is_valid_crush_name(name))
+      return -EINVAL;
     name_map[i] = name;
     if (have_rmaps)
       name_rmap[name] = i;
+    return 0;
   }
 
   // rule names