Skip to content

Commit

Permalink
[PATCH] openpromfs: fix missing NUL
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: "David S. Miller" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jan Engelhardt authored and Linus Torvalds committed Jun 25, 2006
1 parent 2e61139 commit 0928d68
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/openpromfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0928d68

Please sign in to comment.