From 7edc69dc9472d9c744fd4605a883a6706f93503a Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Fri, 1 Dec 2023 21:09:46 +0330 Subject: [PATCH] LibCore: Ignore non-S_IFMT bits in directory_entry_type_from_stat The st_mode field in struct stat is a bitfield of more than just the file type, this commit masks off the non-filetype bits to ensure no unrelated bits are checked. --- Userland/Libraries/LibCore/DirectoryEntry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibCore/DirectoryEntry.cpp b/Userland/Libraries/LibCore/DirectoryEntry.cpp index 13c82b4a68..8790c8ef6a 100644 --- a/Userland/Libraries/LibCore/DirectoryEntry.cpp +++ b/Userland/Libraries/LibCore/DirectoryEntry.cpp @@ -11,7 +11,7 @@ namespace Core { static DirectoryEntry::Type directory_entry_type_from_stat(mode_t st_mode) { - switch (st_mode) { + switch (st_mode & S_IFMT) { case S_IFIFO: return DirectoryEntry::Type::NamedPipe; case S_IFCHR: