]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: check fstatat return value
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 4 Sep 2024 16:26:15 +0000 (18:26 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 6 Sep 2024 21:08:56 +0000 (16:08 -0500)
If fstatat fails, st is not set, which leads to undefined results of
subsequent S_ISDIR call.

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/103
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-config.c

index bdbdfa62ae4d894432f7dcc92349d9ad3ae8dd1d..6b137a5117b3d410163e59852116b94f283fab2e 100644 (file)
@@ -929,7 +929,10 @@ static bool conf_files_filter_out(struct kmod_ctx *ctx, DIR *d,
        if (len < 6 || !streq(&fn[len - 5], ".conf"))
                return true;
 
-       fstatat(dirfd(d), fn, &st, 0);
+       if (fstatat(dirfd(d), fn, &st, 0) < 0) {
+               ERR(ctx, "Cannot stat directory entry: %s/%s\n", path, fn);
+               return true;
+       }
 
        if (S_ISDIR(st.st_mode)) {
                ERR(ctx, "Directories inside directories are not supported: "