From f0e445912658eeb80aa0bf156e778be9185e31bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Fri, 11 Jul 2025 01:04:29 +0200 Subject: [PATCH] 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 --- sys/compat/linuxkpi/common/src/linux_seq_file.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_seq_file.c b/sys/compat/linuxkpi/common/src/linux_seq_file.c index 8b426825cc7..9c06fe27beb 100644 --- a/sys/compat/linuxkpi/common/src/linux_seq_file.c +++ b/sys/compat/linuxkpi/common/src/linux_seq_file.c @@ -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