]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/fetch.c
ITS#8273 Windows file:// URL fixup
[openldap] / libraries / libldap / fetch.c
index b71f890426170ba181b0874aba6d554a088e8cb7..6c65d82f14ebdd419948dec5b3508773c6a15201 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2014 The OpenLDAP Foundation.
+ * Copyright 1999-2015 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
@@ -50,9 +50,22 @@ ldif_open_url(
                /* we don't check for LDAP_DIRSEP since URLs should contain '/' */
                if ( urlstr[0] == '/' && urlstr[1] == '/' ) {
                        urlstr += 2;
-                       /* path must be absolute if authority is present */
-                       if ( urlstr[0] != '/' )
+                       /* path must be absolute if authority is present
+                        * technically, file://hostname/path is also legal but we don't
+                        * accept a non-empty hostname
+                        */
+                       if ( urlstr[0] != '/' ) {
+#ifdef _WIN32
+                               /* An absolute path in improper file://C:/foo/bar format */
+                               if ( urlstr[1] != ':' )
+#endif
                                return NULL;
+                       }
+#ifdef _WIN32
+                       /* An absolute path in proper file:///C:/foo/bar format */
+                       if ( urlstr[2] == ':' )
+                               urlstr++;
+#endif
                }
 
                p = ber_strdup( urlstr );