]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Check amount of memories
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 30 Sep 2024 15:05:23 +0000 (17:05 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 1 Oct 2024 14:12:30 +0000 (09:12 -0500)
The code does not support 65535 or more modules. Since this value is
probably never reached, add a proper check after array building and
do not rely solely on an assert later in code path.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/158
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c

index 876c46d373af37690130bfa73b4fd421268474b7..4718f4d10dc2c606bb2cdc31aac94afdf2daf9b3 100644 (file)
@@ -1428,6 +1428,8 @@ static int depmod_modules_build_array(struct depmod *depmod)
                if (err < 0)
                        return err;
        }
+       if (depmod->modules.count >= UINT16_MAX)
+               return -ERANGE;
 
        return 0;
 }