Bounds do not matter!
This commit is contained in:
parent
45c6c2012d
commit
d28ffd9c3c
@ -25,7 +25,6 @@ static ssize_t universe_read(struct file *file, char __user *buf, size_t count,
|
||||
loff_t *ppos) {
|
||||
struct sst_info *sst_info = (struct sst_info*)file->private_data;
|
||||
char *answer = NULL;
|
||||
int min = 0;
|
||||
size_t len = 0;
|
||||
|
||||
if (sst_consume_answer(sst_info, &answer)) {
|
||||
@ -34,15 +33,11 @@ static ssize_t universe_read(struct file *file, char __user *buf, size_t count,
|
||||
}
|
||||
len = strlen(answer);
|
||||
sst_debug("About to copy %lu bytes of your answer at 0x%lx to the userspace\n", len, (uintptr_t)answer);
|
||||
min = min(len, count);
|
||||
if (min != len) {
|
||||
pr_err("Sorry, your buffer is %lu bytes too small.\n", len - min);
|
||||
}
|
||||
if (copy_to_user(buf, answer, min)) {
|
||||
if (copy_to_user(buf, answer, count)) {
|
||||
pr_err("User copy failed!\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
sst_debug("Copied %u bytes of your answer to the userspace: %s\n", min, answer);
|
||||
sst_debug("Copied %lu bytes of your answer to the userspace: %s\n", count, answer);
|
||||
*ppos += len;
|
||||
kfree(answer);
|
||||
return len;
|
||||
|
Loading…
Reference in New Issue
Block a user