https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8cebbb2b42bfa65ad13c282d47b472b0e73484e3

commit 8cebbb2b42bfa65ad13c282d47b472b0e73484e3
Author:     Corinna Vinschen <[email protected]>
AuthorDate: Fri Feb 21 21:42:43 2025 +0100
Commit:     Corinna Vinschen <[email protected]>
CommitDate: Fri Feb 21 21:56:03 2025 +0100

    Cygwin: fhandler_netdrive::exists: handle WebDAV URLs
    
    WebDAV URLs may contain an at-sign followed by a port number or SSL.
    This will throw GetAddrInfoW, so remove the at-sign prior to calling
    GetAddrInfoW.
    
    Signed-off-by: Corinna Vinschen <[email protected]>

Diff:
---
 winsup/cygwin/fhandler/netdrive.cc | 7 ++++++-
 winsup/cygwin/release/3.6.0        | 6 +++---
 winsup/doc/new-features.xml        | 5 +++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/winsup/cygwin/fhandler/netdrive.cc 
b/winsup/cygwin/fhandler/netdrive.cc
index 08302d20ef74..c05a4766019e 100644
--- a/winsup/cygwin/fhandler/netdrive.cc
+++ b/winsup/cygwin/fhandler/netdrive.cc
@@ -432,7 +432,7 @@ fhandler_netdrive::exists ()
   if (strlen (get_name ()) == 2)
     return virt_rootdir;
 
-  wchar_t name[CYG_MAX_PATH];
+  wchar_t name[CYG_MAX_PATH], *dav_at;
   struct addrinfoW *ai;
   INT ret;
   DWORD protocol = 0;
@@ -458,6 +458,11 @@ fhandler_netdrive::exists ()
      into IP addresses.  This may take up to about 3 secs if the name
      doesn't exist, or about 8 secs if DNS is unavailable. */
   sys_mbstowcs (name, CYG_MAX_PATH, get_name ());
+  /* Webdav URLs contain a @ after the hostname, followed by stuff.
+     Drop @ for GetAddrInfoW to succeed. */
+  if ((dav_at = wcschr (name, L'@')) != NULL)
+    *dav_at = L'\0';
+
   ret = GetAddrInfoW (name + 2, NULL, NULL, &ai);
   if (ret)
     {
diff --git a/winsup/cygwin/release/3.6.0 b/winsup/cygwin/release/3.6.0
index 3f0fb6044395..f749abfdc8df 100644
--- a/winsup/cygwin/release/3.6.0
+++ b/winsup/cygwin/release/3.6.0
@@ -44,9 +44,9 @@ What changed:
   ls //server now also enumerates NFS shares.  If "server" is given
   as a flat name, only SMB shares are enumerated.
 
-- Expose //tsclient (Microsoft Terminal Services) shares as well as
-  //wsl$ (Plan 9 Network Provider) shares, i. e., WSL installation
-  root dirs.
+- Expose WebDav shares, //tsclient (Microsoft Terminal Services)
+  shares as well as //wsl$ (Plan 9 Network Provider) shares, i. e.,
+  WSL installation root dirs.
 
 - Redesign pipe handling to minimize toggling blocking mode.
   The query_hdl stuff is no longer needed in new implementation.
diff --git a/winsup/doc/new-features.xml b/winsup/doc/new-features.xml
index d79abe0db154..0a64d2138b15 100644
--- a/winsup/doc/new-features.xml
+++ b/winsup/doc/new-features.xml
@@ -78,8 +78,9 @@ name, only SMB shares are enumerated.
 </para></listitem>
 
 <listitem><para>
-Expose //tsclient (Microsoft Terminal Services) shares as well as wsl$
-(Plan 9 Network Provider) shares, i. e., WSL installation root dirs.
+Expose WebDav shares, //tsclient (Microsoft Terminal Services) shares as
+well as //wsl$ (Plan 9 Network Provider) shares, i. e., WSL installation
+root dirs.
 </para></listitem>
 
 <listitem><para>

Reply via email to