Skip to content

Commit

Permalink
[PATCH] ebcdic do_kdsk_ioctl off-by-one
Browse files Browse the repository at this point in the history
Add a missing return check from strnlen_user and fixes a off-by-one when
terminating the string with zero.

Signed-off-by: Davi Arnaut <davi.arnaut@gmail.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Davi Arnaut authored and Linus Torvalds committed Feb 1, 2006
1 parent 46d0d2c commit 172411f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/s390/char/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,11 @@ do_kdgkb_ioctl(struct kbd_data *kbd, struct kbsentry __user *u_kbs,
return -EPERM;
len = strnlen_user(u_kbs->kb_string,
sizeof(u_kbs->kb_string) - 1);
p = kmalloc(len, GFP_KERNEL);
if (!len)
return -EFAULT;
if (len > sizeof(u_kbs->kb_string) - 1)
return -EINVAL;
p = kmalloc(len + 1, GFP_KERNEL);
if (!p)
return -ENOMEM;
if (copy_from_user(p, u_kbs->kb_string, len)) {
Expand Down

0 comments on commit 172411f

Please sign in to comment.