[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 1/9] util/id: fully allocate names table
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [PULL 1/9] util/id: fully allocate names table |
Date: |
Fri, 4 Dec 2015 09:57:32 +0300 |
From: John Snow <address@hidden>
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
util/id.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/id.c b/util/id.c
index bcc64d8..7883fbe 100644
--- a/util/id.c
+++ b/util/id.c
@@ -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);
--
2.1.4
- [Qemu-devel] [PULL for-2.5 0/9] Trivial patches for 2015-12-04, Michael Tokarev, 2015/12/04
- [Qemu-devel] [PULL 7/9] scsi: remove scsi_req_free prototype, Michael Tokarev, 2015/12/04
- [Qemu-devel] [PULL 9/9] bt: check struct sizes, Michael Tokarev, 2015/12/04
- [Qemu-devel] [PULL 5/9] configure: use appropriate code fragment for -fstack-protector checks, Michael Tokarev, 2015/12/04
- [Qemu-devel] [PULL 1/9] util/id: fully allocate names table,
Michael Tokarev <=
- [Qemu-devel] [PULL 6/9] gt64xxx: fix decoding of ISD register, Michael Tokarev, 2015/12/04
- [Qemu-devel] [PULL 3/9] configure: Diagnose broken linkers directly, Michael Tokarev, 2015/12/04
- [Qemu-devel] [PULL 2/9] bt: avoid unintended sign extension, Michael Tokarev, 2015/12/04
- [Qemu-devel] [PULL 4/9] crypto: avoid two coverity false positive error reports, Michael Tokarev, 2015/12/04
- [Qemu-devel] [PULL 8/9] typedefs: Put them back into alphabetical order, Michael Tokarev, 2015/12/04
- Re: [Qemu-devel] [PULL for-2.5 0/9] Trivial patches for 2015-12-04, Peter Maydell, 2015/12/04