The branch main has been updated by dumbbell:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f0e445912658eeb80aa0bf156e778be9185e31bc

commit f0e445912658eeb80aa0bf156e778be9185e31bc
Author:     Jean-Sébastien Pédron <dumbb...@freebsd.org>
AuthorDate: 2025-07-10 23:04:29 +0000
Commit:     Jean-Sébastien Pédron <dumbb...@freebsd.org>
CommitDate: 2025-08-09 12:26:25 +0000

    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 8b426825cc78..9c06fe27bebe 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

Reply via email to