lkml.org 
[lkml]   [2004]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] Fix NR_KEYS off-by-one error
OGAWA Hirofumi writes:
> Any comments or suggestions?

How about coding more of this in C instead of in C preprocessor:

--- 2.6.7-mm7/drivers/char/vt_ioctl.c 2004-07-10 17:21:07.000000000 -0700
+++ 2.6.7-mm7.new/drivers/char/vt_ioctl.c 2004-07-28 13:32:47.000000000 -0700
@@ -71,18 +71,26 @@ unsigned char keyboard_type = KB_101;
#define GPLAST 0x3df
#define GPNUM (GPLAST - GPFIRST + 1)

-#define i (tmp.kb_index)
-#define s (tmp.kb_table)
-#define v (tmp.kb_value)
static inline int
do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_struct *kbd)
{
struct kbentry tmp;
ushort *key_map, val, ov;
+ unsigned char s, i;
+ unsigned short v;

if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
return -EFAULT;

+ s = tmp.kb_table;
+ i = tmp.kb_index;
+ v = tmp.kb_value;
+
+ if (s >= ARRAY_SIZE(key_maps))
+ return -EINVAL;
+ if (i >= ARRAY_SIZE(key_map))
+ return -EINVAL;
+
switch (cmd) {
case KDGKBENT:
key_map = key_maps[s];
@@ -155,9 +163,6 @@ do_kdsk_ioctl(int cmd, struct kbentry __
}
return 0;
}
-#undef i
-#undef s
-#undef v

static inline int
do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc, int perm)

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:04    [W:0.398 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site