diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-11-19 22:33:22 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-11-19 22:33:22 +0100 |
commit | f31be45f6811bf26f0a279ff7d4f0035fd3e7862 (patch) | |
tree | 10a2fda08f8f066aa164608fe8decbdc6246bb28 | |
parent | 8976f5e1a26b37d5854cb4ec12c405f7a1b12472 (diff) |
Fixed possible out of bounds array access
-rw-r--r-- | FICS/variable.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/FICS/variable.c b/FICS/variable.c index 29d75ff..f564051 100644 --- a/FICS/variable.c +++ b/FICS/variable.c @@ -33,6 +33,7 @@ #include "stdinclude.h" #include "common.h" +#include <err.h> #include <stdbool.h> #include "board.h" @@ -466,13 +467,18 @@ set_width(int p, char *var, char *val) PUBLIC char * Language(unsigned int i) -{ // XXX +{ static char *Lang[NUM_LANGS] = { "English", "Spanish", "French", "Danish" }; + + if (i >= ARRAY_SIZE(Lang)) { + warnx("%s: invalid arg %u (too large)", __func__, i); + return Lang[0]; + } return Lang[i]; } |