diff options
| author | Markus Uhlin <markus@nifty-networks.net> | 2026-03-28 09:54:51 +0100 |
|---|---|---|
| committer | Markus Uhlin <markus@nifty-networks.net> | 2026-03-28 09:54:51 +0100 |
| commit | 6b9d4569dd64701599f30fbbdd4bd02febeff57c (patch) | |
| tree | 7bb7db32454edec75ecc03244b5ed006ea549d2a /FICS | |
| parent | 5a2ae7abeef3e03dddf62d9a5d9d92642b025e5c (diff) | |
Casted enum to int and added array index bounds checking
Diffstat (limited to 'FICS')
| -rw-r--r-- | FICS/lists.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/FICS/lists.c b/FICS/lists.c index f88d24d..753bc67 100644 --- a/FICS/lists.c +++ b/FICS/lists.c @@ -507,10 +507,18 @@ com_showlist(int p, param_list param) pprintf(p, "Lists:\n\n"); for (i = 0; ListArray[i].name != NULL; i++) { - if ((rights = ListArray[i].rights) > P_ADMIN || + // XXX: casting enum to int + if ((rights = (int)ListArray[i].rights) > P_ADMIN || parray[p].adminLevel >= ADMIN_ADMIN) { - pprintf(p, "%-20s is %s\n", ListArray[i].name, - rightnames[rights]); + if (rights < 0 || + (size_t)rights >= ARRAY_SIZE(rightnames)) { + warnx("%s: out-of-bounds array index " + "detected", __func__); + } else { + pprintf(p, "%-20s is %s\n", + ListArray[i].name, + rightnames[rights]); + } } } } else { // find match in index |
