Commit 92d07e42 authored by Steve Holland's avatar Steve Holland Committed by Greg Kroah-Hartman

USB: usbtmc: inhibit corruption

Limit data copied to userspace to amount requested.  Prevents a faulty
instrument from overwriting user memory.
Signed-off-by: default avatarSteve Holland <sdh4@iastate.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c2cd26e1
......@@ -473,6 +473,10 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
n_characters = this_part;
}
/* Bound amount of data received by amount of data requested */
if (n_characters > this_part)
n_characters = this_part;
/* Copy buffer to user space */
if (copy_to_user(buf + done, &buffer[12], n_characters)) {
/* There must have been an addressing problem */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment