Re: [PATCH] Fix NR_KEYS off-by-one error

From: Andries Brouwer
Date: Fri Jul 16 2004 - 15:17:13 EST

On Sat, Jul 17, 2004 at 01:35:59AM +0900, OGAWA Hirofumi wrote:

:: KDGKBENT ioctl can use 256 entries (0-255), but it was defined as
:: key_map[NR_KEYS] (NR_KEYS == 255). The code seems also thinking it's 256.
:: key_map[0] = U(K_ALLOCATED);
:: for (j = 1; j < NR_KEYS; j++)
:: key_map[j] = U(K_HOLE);

I think the code has no opinion. It was 128 in 2.4.
I am not aware of assumptions on NR_KEYS.
So, do not think this is an off-by-one error.
Vojtech did this intentionally.

However, I have no objections. In fact loadkeys uses 256.

On Fri, Jul 16, 2004 at 06:44:35PM +0200, Vojtech Pavlik wrote:

> The patch might cause problems, though, because some apps may (in
> old versions are) using a char variable to index up to NR_KEYS,
> which leads to an endless loop.

The binaries will still work. If the utility is recompiled, against
recent kernel headers, then the person doing that is responsible
for the result.

I just checked kbd, but there are no such char variables there.
Do you have specific utilities in mind? Is X OK?

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at