From 14e9635241fca41a7ba153040368256612ccb16f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 14 Jun 2016 16:24:51 +0300 Subject: Check path validity in path::init() on Windows --- butl/path.txx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'butl/path.txx') diff --git a/butl/path.txx b/butl/path.txx index 56e2cf1..383f7fe 100644 --- a/butl/path.txx +++ b/butl/path.txx @@ -246,10 +246,21 @@ namespace butl bool basic_path:: init (string_type& s, bool exact) { + size_type n (s.size ()); + +#ifdef _WIN32 + // We do not support any special Windows path name notations like in C:abc, + // \\?\c:\abc, \\server\abc and \\?\UNC\server\abc (more about them at + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx). + // + if ((n > 2 && s[1] == ':' && s[2] != '\\' && s[2] != '/') || + (n > 1 && s[0] == '\\' && s[1] == '\\')) + throw invalid_basic_path (s); +#endif + // Strip trailing slashes except for the case where the single // slash represents the root directory. // - size_type n (s.size ()); for (; n > 1 && traits::is_separator (s[n - 1]); --n) ; if (n != s.size ()) -- cgit v1.1