2006-08-13 21:09:11

by Florin Malita

[permalink] [raw]
Subject: [PATCH] atkbd.c: overrun in atkbd_set_repeat_rate()

This was introduced in commit 3d0f0fa0cb554541e10cb8cb84104e4b10828468:
bounds checking is performed against period[32] while indexing delay[4].

Spotted by Coverity, CID 1376.

Signed-off-by: Florin Malita <[email protected]>
---

diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 6bfa0cf..a86afd0 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -498,7 +498,7 @@ static int atkbd_set_repeat_rate(struct
i++;
dev->rep[REP_PERIOD] = period[i];

- while (j < ARRAY_SIZE(period) - 1 && delay[j] < dev->rep[REP_DELAY])
+ while (j < ARRAY_SIZE(delay) - 1 && delay[j] < dev->rep[REP_DELAY])
j++;
dev->rep[REP_DELAY] = delay[j];




2006-08-13 23:50:32

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] atkbd.c: overrun in atkbd_set_repeat_rate()

On Sunday 13 August 2006 17:10, Florin Malita wrote:
> This was introduced in commit 3d0f0fa0cb554541e10cb8cb84104e4b10828468:
> bounds checking is performed against period[32] while indexing delay[4].
>
> Spotted by Coverity, CID 1376.
>

Will apply, thank you.

> Signed-off-by: Florin Malita <[email protected]>
> ---
>
> diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
> index 6bfa0cf..a86afd0 100644
> --- a/drivers/input/keyboard/atkbd.c
> +++ b/drivers/input/keyboard/atkbd.c
> @@ -498,7 +498,7 @@ static int atkbd_set_repeat_rate(struct
> i++;
> dev->rep[REP_PERIOD] = period[i];
>
> - while (j < ARRAY_SIZE(period) - 1 && delay[j] < dev->rep[REP_DELAY])
> + while (j < ARRAY_SIZE(delay) - 1 && delay[j] < dev->rep[REP_DELAY])
> j++;
> dev->rep[REP_DELAY] = delay[j];
>
>
>

--
Dmitry