You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The From<FileMode> implementation for FileType uses the bitflags contains function to check the file mode against the FileMode enum members, e.g. mode.contains(FileMode::DIR).
However, the file modes are not flags - their set bits overlap.
As a result, the FileType will be wrong for certain file modes.
Example:
The file is a socket, file mode 0xC000 == 1100000000000000.
The first test is against FileMode::DIR which is 0x4000 == 100000000000000.
Since all set bits in 110000000000000 are also set in 1000000000000000, the check succeeds and the file type is set to FileType::Dir.
The text was updated successfully, but these errors were encountered:
bspot
linked a pull request
Jun 1, 2024
that will
close
this issue
The
From<FileMode>
implementation forFileType
uses the bitflagscontains
function to check the file mode against theFileMode
enum members, e.g.mode.contains(FileMode::DIR)
.However, the file modes are not flags - their set bits overlap.
As a result, the
FileType
will be wrong for certain file modes.Example:
The file is a socket, file mode
0xC000 == 1100000000000000
.The first test is against
FileMode::DIR
which is0x4000 == 100000000000000
.Since all set bits in
110000000000000
are also set in1000000000000000
, the check succeeds and the file type is set toFileType::Dir
.The text was updated successfully, but these errors were encountered: