]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: sysctl: do not reserve an extra char in dump_cpumask temporary buffer
authorAntoine Tenart <atenart@kernel.org>
Thu, 17 Oct 2024 15:24:18 +0000 (17:24 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Wed, 23 Oct 2024 08:28:19 +0000 (10:28 +0200)
When computing the length we'll be able to use out of the buffers, one
char is removed from the temporary one to make room for a newline. It
should be removed from the output buffer length too, but in reality this
is not needed as the later call to scnprintf makes sure a null char is
written at the end of the buffer which we override with the newline.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/core/sysctl_net_core.c

index e7c0121dfaa1616da05f98376c07331618dbbcb5..8dc07f7b1772ec738aa3ff57d98a1973ca642f2e 100644 (file)
@@ -62,7 +62,7 @@ static void dump_cpumask(void *buffer, size_t *lenp, loff_t *ppos,
                return;
        }
 
-       len = min(sizeof(kbuf) - 1, *lenp);
+       len = min(sizeof(kbuf), *lenp);
        len = scnprintf(kbuf, len, "%*pb", cpumask_pr_args(mask));
        if (!len) {
                *lenp = 0;