From 6e11b5ae1ff033381e74a91aa36574698995630b Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Wed, 3 Sep 2025 16:47:17 +0200 Subject: [PATCH] fix: implement the `--no-follow-symlinks` option in Windows. Until now this option was working only on POSIX systems. --- cli/yara.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cli/yara.c b/cli/yara.c index e5902cb9..9b6829e2 100644 --- a/cli/yara.c +++ b/cli/yara.c @@ -500,6 +500,14 @@ static int scan_dir(const char_t* dir, SCAN_OPTIONS* scan_opts) { _sntprintf(path, YR_MAX_PATH, _T("%s\\%s"), dir, FindFileData.cFileName); + // If symbolic links must not be followed, and this entry is a symbolic + // link, ignore it and continue with the next one. + if (!scan_opts.follow_symlinks && + FindFileData.dwFileAttribute & FILE_ATTRIBUTE_REPARSE_POINT) + { + continue; + } + if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { LARGE_INTEGER file_size;