From cf06f991f927503cfca05846eb7f19a2925df03d Mon Sep 17 00:00:00 2001 From: bagajjal Date: Fri, 15 Apr 2022 13:49:41 -0700 Subject: [PATCH] CHROOT - fix symbolic link that refers to a network share (#596) --- contrib/win32/openssh/OpenSSH-build.ps1 | 3 +-- contrib/win32/win32compat/fileio.c | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/win32/openssh/OpenSSH-build.ps1 b/contrib/win32/openssh/OpenSSH-build.ps1 index 7601ce25c..2cfeff5cf 100644 --- a/contrib/win32/openssh/OpenSSH-build.ps1 +++ b/contrib/win32/openssh/OpenSSH-build.ps1 @@ -46,5 +46,4 @@ try finally { Pop-Location -} - +} \ No newline at end of file diff --git a/contrib/win32/win32compat/fileio.c b/contrib/win32/win32compat/fileio.c index 11d658d11..b99773232 100644 --- a/contrib/win32/win32compat/fileio.c +++ b/contrib/win32/win32compat/fileio.c @@ -427,6 +427,14 @@ file_in_chroot_jail(HANDLE handle) { if (!final_path) return 0; + const wchar_t* uncPrefix = L"UNC\\"; + int isUNCPath = memcmp(final_path, uncPrefix, 2 * wcslen(uncPrefix)); + + if (0 == isUNCPath) { + debug3("symlink points to UNCPath"); + return 1; + } + to_wlower_case(final_path); if ((wcslen(final_path) < wcslen(chroot_pathw)) || memcmp(final_path, chroot_pathw, 2 * wcslen(chroot_pathw)) != 0 ||