From eb9a2c3ae76b862254669b798b51b2b848616b6a Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Tue, 7 Apr 2015 13:51:23 -0700 Subject: ICE-6402 - IceSSL.DefaultDir fixes --- csharp/src/IceSSL/SSLEngine.cs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'csharp/src') diff --git a/csharp/src/IceSSL/SSLEngine.cs b/csharp/src/IceSSL/SSLEngine.cs index deac22369a3..04b457bb7b3 100644 --- a/csharp/src/IceSSL/SSLEngine.cs +++ b/csharp/src/IceSSL/SSLEngine.cs @@ -734,6 +734,35 @@ namespace IceSSL } } + private static bool isAbsolutePath(string path) + { + // + // Skip whitespace + // + path = path.Trim(); + + // + // We need at least 3 non-whitespace characters to have an absolute path + // + if(path.Length < 3) + { + return false; + } + + // + // Check for X:\ path ('\' may have been converted to '/') + // + if((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z')) + { + return path[1] == ':' && (path[2] == '\\' || path[2] == '/'); + } + + // + // Check for UNC path + // + return (path[0] == '\\' && path[1] == '\\') || path[0] == '/'; + } + private bool checkPath(ref string path) { if(File.Exists(path)) @@ -741,7 +770,7 @@ namespace IceSSL return true; } - if(_defaultDir.Length > 0) + if(_defaultDir.Length > 0 && !isAbsolutePath(path)) { string s = _defaultDir + Path.DirectorySeparatorChar + path; if(File.Exists(s)) -- cgit v1.2.3