diff options
| author | John Snow | 2015-11-25 22:03:37 +0100 |
|---|---|---|
| committer | Michael Tokarev | 2015-12-04 07:39:55 +0100 |
| commit | 624533e5a53e5df347e46f06408d15b9df5254f0 (patch) | |
| tree | a5f33fcc5fb9791e2f7edb49ba3627289f9e5ecc | |
| parent | ui: vnc: avoid floating point exception (diff) | |
| download | qemu-624533e5a53e5df347e46f06408d15b9df5254f0.tar.gz qemu-624533e5a53e5df347e46f06408d15b9df5254f0.tar.xz qemu-624533e5a53e5df347e46f06408d15b9df5254f0.zip | |
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: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
| -rw-r--r-- | util/id.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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); |
