From d86fa2e9a6dff3a907549ef2b3e485517dca359e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 Jun 2010 16:20:15 +0200 Subject: Use normalized base path to construct absolute path This prevents us from hitting a system limit on path lengths with path moving up and down with '..'. --- xsd-frontend/parser.cxx | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'xsd-frontend') diff --git a/xsd-frontend/parser.cxx b/xsd-frontend/parser.cxx index 0f71fa3..576a7ca 100644 --- a/xsd-frontend/parser.cxx +++ b/xsd-frontend/parser.cxx @@ -1683,12 +1683,28 @@ namespace XSDFrontend // Path stack for diagnostic. // - Cult::Containers::Stack file_stack_; + struct PathPair + { + PathPair (SemanticGraph::Path const& r, SemanticGraph::Path const& a) + : rel (r), abs (a) + { + } + + SemanticGraph::Path rel, abs; + }; + + Cult::Containers::Stack file_stack_; SemanticGraph::Path const& file () { - return file_stack_.top (); + return file_stack_.top ().rel; + } + + SemanticGraph::Path const& + abs_file () + { + return file_stack_.top ().abs; } // Members with default/fixed values (needed for QName handling). @@ -1914,7 +1930,7 @@ namespace XSDFrontend s_ = cur_ = rs.get (); { - file_stack_.push (tu); + file_stack_.push (PathPair (tu, abs_path)); { push_scope ( @@ -2156,7 +2172,7 @@ namespace XSDFrontend cur_ = &s; { - file_stack_.push (tu); + file_stack_.push (PathPair (tu, abs_path)); { push_scope ( @@ -2433,8 +2449,11 @@ namespace XSDFrontend } else { + // Use abs_file to construct the absolute path to avoid + // hitting system path limits with '..' directories. + // rel_path = file ().branch_path () / path; - abs_path = system_complete (rel_path); + abs_path = system_complete (abs_file ().branch_path () / path); } abs_path.normalize (); @@ -2481,7 +2500,7 @@ namespace XSDFrontend cur_chameleon_ = false; { - file_stack_.push (rel_path); + file_stack_.push (PathPair (rel_path, abs_path)); { push_scope ( @@ -2537,8 +2556,11 @@ namespace XSDFrontend } else { + // Use abs_file to construct the absolute path to avoid + // hitting system path limits with '..' directories. + // rel_path = file ().branch_path () / path; - abs_path = system_complete (rel_path); + abs_path = system_complete (abs_file ().branch_path () / path); } abs_path.normalize (); @@ -2613,7 +2635,7 @@ namespace XSDFrontend cur_chameleon_ = chameleon; { - file_stack_.push (rel_path); + file_stack_.push (PathPair (rel_path, abs_path)); { push_scope ( -- cgit v1.1