提交 624533e5 编写于 作者: J John Snow 提交者: Michael Tokarev

util/id: fully allocate names table

Trivial: this array should be allocated to have ID_MAX entries always.
Otherwise if someone were to forget to expand this table, the assertion
in the id generator won't actually trigger; it will read junk data.
Signed-off-by: NJohn Snow <jsnow@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NJeff Cody <jcody@redhat.com>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 4c65fed8
......@@ -29,7 +29,7 @@ bool id_wellformed(const char *id)
#define ID_SPECIAL_CHAR '#'
static const char *const id_subsys_str[] = {
static const char *const id_subsys_str[ID_MAX] = {
[ID_QDEV] = "qdev",
[ID_BLOCK] = "block",
};
......@@ -53,7 +53,7 @@ char *id_generate(IdSubSystems id)
static uint64_t id_counters[ID_MAX];
uint32_t rnd;
assert(id < ID_MAX);
assert(id < ARRAY_SIZE(id_subsys_str));
assert(id_subsys_str[id]);
rnd = g_random_int_range(0, 100);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册