mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 23:27:06 +00:00
staging/lustre: Use proper number of bytes in copy_from_user
This patch removes the usage of MAX_STRING_SIZE from copy_from_user() and just copies enough bytes to cover count passed in. Signed-off-by: Jian Yu <jian.yu@intel.com> Reviewed-on: http://review.whamcloud.com/23462 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8774 Reviewed-by: John L. Hammond <john.hammond@intel.com> Signed-off-by: Oleg Drokin <green@linuxhacker.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
354872712e
commit
8d130c3b0f
1 changed files with 9 additions and 2 deletions
|
@ -400,10 +400,17 @@ int lprocfs_wr_uint(struct file *file, const char __user *buffer,
|
|||
char dummy[MAX_STRING_SIZE + 1], *end;
|
||||
unsigned long tmp;
|
||||
|
||||
dummy[MAX_STRING_SIZE] = '\0';
|
||||
if (copy_from_user(dummy, buffer, MAX_STRING_SIZE))
|
||||
if (count >= sizeof(dummy))
|
||||
return -EINVAL;
|
||||
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
if (copy_from_user(dummy, buffer, count))
|
||||
return -EFAULT;
|
||||
|
||||
dummy[count] = '\0';
|
||||
|
||||
tmp = simple_strtoul(dummy, &end, 0);
|
||||
if (dummy == end)
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Reference in a new issue