Commit 0928d68056fa25456830b1de9f0ee89bc37447cd
Committed by
Linus Torvalds
1 parent
2e6113908f
Exists in
master
and in
4 other branches
[PATCH] openpromfs: fix missing NUL
tchars is not '\0'-terminated so the strtoul may run into problems. Fix that. Also make tchars as big as a long in hexadecimal form would take rather than just 16. Signed-off-by: Jan Engelhardt <jengelh@gmx.de> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 3 additions and 2 deletions Side-by-side Diff
fs/openpromfs/inode.c
... | ... | @@ -448,10 +448,11 @@ |
448 | 448 | *q |= simple_strtoul (tmp, NULL, 16); |
449 | 449 | buf += last_cnt; |
450 | 450 | } else { |
451 | - char tchars[17]; /* XXX yuck... */ | |
451 | + char tchars[2 * sizeof(long) + 1]; | |
452 | 452 | |
453 | - if (copy_from_user(tchars, buf, 16)) | |
453 | + if (copy_from_user(tchars, buf, sizeof(tchars) - 1)) | |
454 | 454 | return -EFAULT; |
455 | + tchars[sizeof(tchars) - 1] = '\0'; | |
455 | 456 | *q = simple_strtoul (tchars, NULL, 16); |
456 | 457 | buf += 9; |
457 | 458 | } |