From 20f4fdee338a202fbabab67d86e05db994c491b1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 20 Apr 2009 08:42:05 -0400 Subject: [PATCH] BUG: Fix SystemTools::IsSubDirectory on bad input When SystemTools::GetParentDirectory was fixed to never remove the root path component from a full path we violated an assumption made by IsSubDirectory that eventually GetParentDirectory returns an empty string. This led to an infinite loop if the potential parent directory is empty, so we explicitly avoid that case. --- Source/kwsys/SystemTools.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 814c4173c..2dd321355 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -3980,6 +3980,10 @@ kwsys_stl::string SystemTools::GetParentDirectory(const char* fileOrDir) bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir) { + if(!*cDir) + { + return false; + } kwsys_stl::string subdir = cSubdir; kwsys_stl::string dir = cDir; SystemTools::ConvertToUnixSlashes(dir);