Skip to content

Commit f0e4459

Browse files
committed
linuxkpi: Update posittion after copy in seq_read()
`seq_read()` is usually called in a loop because the destination buffer might be smaller than the source. The caller relies on the updated position to read what is next. We also use `memcpy()` instead of `strscpy()` because we don't need to append a NUL character. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51560
1 parent 7cbc4d8 commit f0e4459

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sys/compat/linuxkpi/common/src/linux_seq_file.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,10 @@ seq_read(struct linux_file *f, char *ubuf, size_t size, off_t *ppos)
6464
return (-EINVAL);
6565

6666
size = min(rc - *ppos, size);
67-
rc = strscpy(ubuf, sbuf_data(sbuf) + *ppos, size + 1);
67+
memcpy(ubuf, sbuf_data(sbuf) + *ppos, size);
68+
*ppos += size;
6869

69-
/* add 1 for null terminator */
70-
if (rc > 0)
71-
rc += 1;
72-
73-
return (rc);
70+
return (size);
7471
}
7572

7673
int

0 commit comments

Comments
 (0)