Skip to content

Commit 0928d68

Browse files
Jan EngelhardtLinus Torvalds
authored andcommitted
[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>
1 parent 2e61139 commit 0928d68

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎fs/openpromfs/inode.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,11 @@ static ssize_t property_write(struct file *filp, const char __user *buf,
448448
*q |= simple_strtoul (tmp, NULL, 16);
449449
buf += last_cnt;
450450
} else {
451-
char tchars[17]; /* XXX yuck... */
451+
char tchars[2 * sizeof(long) + 1];
452452

453-
if (copy_from_user(tchars, buf, 16))
453+
if (copy_from_user(tchars, buf, sizeof(tchars) - 1))
454454
return -EFAULT;
455+
tchars[sizeof(tchars) - 1] = '\0';
455456
*q = simple_strtoul (tchars, NULL, 16);
456457
buf += 9;
457458
}

0 commit comments

Comments
 (0)