diff options
author | Jan Engelhardt <jengelh@gmx.de> | 2006-06-25 05:47:35 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 10:01:05 -0700 |
commit | 0928d68056fa25456830b1de9f0ee89bc37447cd (patch) | |
tree | eafca87385013b4ff11a11192de048a0e0a0b3b3 | |
parent | 2e6113908fe76a06295cb243f1f2f0eea055b0c2 (diff) | |
download | linux-0928d68056fa25456830b1de9f0ee89bc37447cd.tar.gz linux-0928d68056fa25456830b1de9f0ee89bc37447cd.tar.bz2 linux-0928d68056fa25456830b1de9f0ee89bc37447cd.zip |
[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>
-rw-r--r-- | fs/openpromfs/inode.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c index 464e2bce0203..c0cbe97cdc60 100644 --- a/fs/openpromfs/inode.c +++ b/fs/openpromfs/inode.c @@ -448,10 +448,11 @@ static ssize_t property_write(struct file *filp, const char __user *buf, *q |= simple_strtoul (tmp, NULL, 16); buf += last_cnt; } else { - char tchars[17]; /* XXX yuck... */ + char tchars[2 * sizeof(long) + 1]; - if (copy_from_user(tchars, buf, 16)) + if (copy_from_user(tchars, buf, sizeof(tchars) - 1)) return -EFAULT; + tchars[sizeof(tchars) - 1] = '\0'; *q = simple_strtoul (tchars, NULL, 16); buf += 9; } |