]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crush/CrushWrapper: fix decoding of choose_args weight-set
authorSage Weil <sage@redhat.com>
Thu, 13 Jul 2017 21:33:53 +0000 (17:33 -0400)
committerSage Weil <sage@redhat.com>
Fri, 21 Jul 2017 17:50:48 +0000 (13:50 -0400)
Assert that ids_size matches the bucket while we are at it.

Signed-off-by: Sage Weil <sage@redhat.com>
src/crush/CrushWrapper.cc

index e6f221944e6024d093754f175b719421bcd06964..1c49f19bc5b20b17a88e980f12e215a3aa19f3fc 100644 (file)
@@ -1990,9 +1990,12 @@ void CrushWrapper::decode(bufferlist::iterator& blp)
              ::decode(weight_set->weights[l], blp);
          }
          ::decode(arg->ids_size, blp);
-         arg->ids = (__s32 *)calloc(arg->ids_size, sizeof(__s32));
-         for (__u32 k = 0; k < arg->ids_size; k++)
-           ::decode(arg->ids[k], blp);
+         if (arg->ids_size) {
+           assert(arg->ids_size == crush->buckets[bucket_index]->size);
+           arg->ids = (__s32 *)calloc(arg->ids_size, sizeof(__s32));
+           for (__u32 k = 0; k < arg->ids_size; k++)
+             ::decode(arg->ids[k], blp);
+         }
        }
        choose_args[choose_args_index] = arg_map;
       }