From acbd9bd0c8c1b00a0130cdab6a14d74224c243f9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 28 Jul 2003 09:08:49 +0000 Subject: TP Diffenbach pointed out the risk here. Added a check for bad input values here, and I also made the argument named 'index' and made it unsigned to better match what it actually is used for. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3899 a1c6a512-1295-4272-9138-f99709370657 --- firmware/backlight.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/firmware/backlight.c b/firmware/backlight.c index 887e5943f1..5173d7819c 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c @@ -39,7 +39,7 @@ static bool charger_was_inserted = 0; static bool backlight_on_when_charging = 0; static int backlight_timer; -static int backlight_timeout = 5; +static unsigned int backlight_timeout = 5; const char backlight_timeout_value[19] = { @@ -125,9 +125,12 @@ int backlight_get_timeout(void) return backlight_timeout; } -void backlight_set_timeout(int seconds) +void backlight_set_timeout(unsigned int index) { - backlight_timeout = seconds; + if(index >= sizeof(backlight_timeout_value)) + /* if given a weird value, use 0 */ + index=0; + backlight_timeout = index; /* index in the backlight_timeout_value table */ backlight_on(); } -- cgit v1.2.3