From 4a9760afe097fcce1ac11b4f4c902a18905655e4 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 5 Mar 2025 14:22:37 -0800 Subject: [PATCH] Incorrect array_size test. ARRAY_SIZE(...) will return `3` for this array with members from 0 to 2, therefore arr[3] is out of bounds. The array length test is off by one and needs fixing. Signed-off-by: Auke Kok --- kmod/src/quorum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kmod/src/quorum.c b/kmod/src/quorum.c index 7c385448..242804ed 100644 --- a/kmod/src/quorum.c +++ b/kmod/src/quorum.c @@ -1062,7 +1062,7 @@ static char *role_str(int role) [LEADER] = "leader", }; - if (role < 0 || role > ARRAY_SIZE(roles) || !roles[role]) + if (role < 0 || role >= ARRAY_SIZE(roles) || !roles[role]) return "invalid"; return roles[role];