]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Check fstatat return value
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 6 Nov 2024 21:22:35 +0000 (22:22 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 7 Nov 2024 20:31:20 +0000 (14:31 -0600)
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 <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/230
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c

index a33b38a135542ceb2a4e494f54e6cf233a057b7d..a1ba388d61e9afa3e6c1ca2dad189ab286b31f13 100644 (file)
@@ -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);