fitzgen / is_executable

Is there an executable file at the given path?
Apache License 2.0
17 stars 8 forks source link

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

Closed lucieleblanc closed 2 weeks ago

lucieleblanc commented 3 weeks ago

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)