We don't need to conditionally use O_DIRECTORY when opening a
directory. Remove the unneeded stat, and a TOCTOU complaint from
Coverity.
Fixes-Coverity-Bug: 1293497
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
static void do_get_policy(int argc, char **argv, const struct cmd_desc *cmd)
{
struct ext4_encryption_policy policy;
- struct stat st;
int i, j, fd, rc;
if (argc < 2) {
}
for (i = 1; i < argc; i++) {
- if (stat(argv[i], &st) < 0) {
- perror(argv[i]);
- continue;
- }
- fd = open(argv[i],
- S_ISDIR(st.st_mode) ? O_DIRECTORY : O_RDONLY);
+ fd = open(argv[i], O_RDONLY);
if (fd == -1) {
perror(argv[i]);
exit(1);