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
This commit is contained in:
Jean-Sébastien Pédron 2025-07-11 01:04:29 +02:00
parent 7cbc4d8759
commit f0e4459126
No known key found for this signature in database
GPG key ID: 39E99761A5FD94CC

View file

@ -64,13 +64,10 @@ seq_read(struct linux_file *f, char *ubuf, size_t size, off_t *ppos)
return (-EINVAL);
size = min(rc - *ppos, size);
rc = strscpy(ubuf, sbuf_data(sbuf) + *ppos, size + 1);
memcpy(ubuf, sbuf_data(sbuf) + *ppos, size);
*ppos += size;
/* add 1 for null terminator */
if (rc > 0)
rc += 1;
return (rc);
return (size);
}
int