From 0416366e2de26077b3de548be4a74c2f0ddb3289 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 26 Aug 2026 09:09:32 +0200 Subject: [PATCH] Handle trailing-slash paths in Windows lstat using handle-based states starting --- os/mingw.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/os/mingw.c b/os/mingw.c index 1a0bc506..0d691744 100644 --- a/os/mingw.c +++ b/os/mingw.c @@ -748,6 +748,15 @@ int windows_lstat(const char* file, struct windows_stat* st) wchar_t conv_buf[CONV_MAX]; HANDLE h; WIN32_FIND_DATAW data; + size_t len = strlen(file); + + /* + * A trailing slash requires resolving the final component as a directory. + * Use the handle-based implementation because FindFirstFileW() rejects the + * trailing slash, while preserving its faster path for all normal entries. + */ + if (len != 0 && is_slash(file[len - 1])) + return windows_stat(file, st); /* FindFirstFileW by default gets information of symbolic links and not of their targets */ h = FindFirstFileW(convert(conv_buf, file), &data);