From: Tobias Stoeckmann Date: Mon, 30 Sep 2024 15:05:23 +0000 (+0200) Subject: depmod: Check amount of memories X-Git-Tag: v34~275 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ea16db2c0e3b5c3f3de82b517af9f91dc3e7de4e;p=thirdparty%2Fkmod.git depmod: Check amount of memories 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 Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/158 Signed-off-by: Lucas De Marchi --- diff --git a/tools/depmod.c b/tools/depmod.c index 876c46d3..4718f4d1 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -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; }