]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
tools: specify buffer to be size PATH_MAX
authorGrayson Nocera <gnocera@purdue.edu>
Mon, 25 Nov 2024 20:33:02 +0000 (15:33 -0500)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 3 Jan 2025 00:20:49 +0000 (18:20 -0600)
Using a CodeQL query, I discovered that the destination of a `sscanf` call could overflow.
Thus, we bound the buffer size to be PATH_MAX, to ensure that it is
not larger than `modname` or `devname`.

Signed-off-by: Grayson Nocera <gnocera@purdue.edu>
Suggested-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/260
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/static-nodes.c

index 4914d0c32a728bf410e0473ad168a43314aef08b..0ecb9030aa6293c167fbd2f8d50e90600b6758b8 100644 (file)
@@ -144,7 +144,7 @@ static void help(void)
 static int do_static_nodes(int argc, char *argv[])
 {
        struct utsname kernel;
-       char modules[PATH_MAX], buf[4096];
+       char modules[PATH_MAX], buf[PATH_MAX];
        const char *output = "/dev/stdout";
        FILE *in = NULL, *out = NULL;
        const struct static_nodes_format *format = &static_nodes_format_human;