提交 0928d680 编写于 作者: J Jan Engelhardt 提交者: Linus Torvalds

[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: NJan Engelhardt <jengelh@gmx.de>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 2e611390
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册