From f15cb60a3e689fb546f90b47ea0644c20c7b2cc2 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 16 Jun 2022 17:56:15 +0000 Subject: On 1.8.x-r1896717 branch: Backport r1896717: Fix a regression in apr_stat() for root path on Windows caused by the extended symlink detection added in r1855949 (PR47630) [1]. See [2] for the detailed problem report and discussion. [1] https://bz.apache.org/bugzilla/show_bug.cgi?id=47630 [2] https://lists.apache.org/thread/18x2jb81nf6zrjsnwf1k2wwooprkp0p5 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x-r1896717@1901988 13f79535-47bb-0310-9956-ffa450edef68 --- file_io/win32/filestat.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c index c90b9abc0..5ddee7f29 100644 --- a/file_io/win32/filestat.c +++ b/file_io/win32/filestat.c @@ -624,7 +624,7 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, if ((rv = utf8_to_unicode_path(wfname, sizeof(wfname) / sizeof(apr_wchar_t), fname))) return rv; - if (!(wanted & (APR_FINFO_NAME | APR_FINFO_LINK))) { + if (!(wanted & APR_FINFO_NAME)) { if (!GetFileAttributesExW(wfname, GetFileExInfoStandard, &FileInfo.i)) return apr_get_os_error(); @@ -634,6 +634,7 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, * since we want the true name, and set aside a long * enough string to handle the longest file name. */ + char tmpname[APR_FILE_MAX * 3 + 1]; HANDLE hFind; if ((rv = test_safe_name(fname)) != APR_SUCCESS) { return rv; @@ -644,15 +645,11 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, FindClose(hFind); finddata = 1; - if (wanted & APR_FINFO_NAME) - { - char tmpname[APR_FILE_MAX * 3 + 1]; - if (unicode_to_utf8_path(tmpname, sizeof(tmpname), - FileInfo.w.cFileName)) { - return APR_ENAMETOOLONG; - } - filename = apr_pstrdup(pool, tmpname); + if (unicode_to_utf8_path(tmpname, sizeof(tmpname), + FileInfo.w.cFileName)) { + return APR_ENAMETOOLONG; } + filename = apr_pstrdup(pool, tmpname); } } #endif -- cgit v1.2.1