From: Tobias Stoeckmann Date: Wed, 6 Nov 2024 21:22:35 +0000 (+0100) Subject: depmod: Check fstatat return value X-Git-Tag: v34~129 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a55c094d2168f79089f7c40f93661f4fb388513f;p=thirdparty%2Fkmod.git depmod: Check fstatat return value If fstatat fails, do not access the uninitialized variable st. Instead, filter the file out. Basically synchronization with libkmod's conf_files_filter_out. Signed-off-by: Tobias Stoeckmann Link: https://github.com/kmod-project/kmod/pull/230 Signed-off-by: Lucas De Marchi --- diff --git a/tools/depmod.c b/tools/depmod.c index a33b38a1..a1ba388d 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -714,7 +714,11 @@ static int cfg_files_filter_out(DIR *d, const char *dir, const char *name) return 1; } - fstatat(dirfd(d), name, &st, 0); + if (fstatat(dirfd(d), name, &st, 0) < 0) { + ERR("Cannot stat directory entry: %s%s\n", dir, name); + return 1; + } + if (S_ISDIR(st.st_mode)) { ERR("Directories inside directories are not supported: %s/%s\n", dir, name);