Skip to content

Any path string ending in .exe returns true on Windows, even if the file doesn't exist #13

@lucieleblanc

Description

@lucieleblanc

The documentation states that is_executable returns true if there is a file at the given path and it is executable, and returns false otherwise.

However, on Windows, is_executable doesn't check that the path points to an actual file if the extension looks correct.

To see this in action, pass in any non-existent path ending in ".exe":

use is_executable::is_executable;
use std::path::PathBuf;

fn main() {
    println!("{}", is_executable(PathBuf::from("C:\\nonexistent.exe")));
}

Even though the file nonexistent.exe doesn't exist, the program only checks that the string ends in a valid extension and prints:

true

(is_executable version: 1.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions