From f31be45f6811bf26f0a279ff7d4f0035fd3e7862 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Tue, 19 Nov 2024 22:33:22 +0100 Subject: Fixed possible out of bounds array access --- FICS/variable.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'FICS') 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 #include #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]; } -- cgit v1.2.3