From d590780d93c6f3168517e7fbf70adbec512a2796 Mon Sep 17 00:00:00 2001 From: Brad King <brad.king@kitware.com> 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. --- SystemTools.cxx | 4 ++++ kwsysDateStamp.cmake | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index 6b4ad1a..c09001b 100644 --- a/SystemTools.cxx +++ b/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); diff --git a/kwsysDateStamp.cmake b/kwsysDateStamp.cmake index 21aeaab..65f81e6 100644 --- a/kwsysDateStamp.cmake +++ b/kwsysDateStamp.cmake @@ -7,4 +7,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2009) SET(KWSYS_DATE_STAMP_MONTH 04) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 15) +SET(KWSYS_DATE_STAMP_DAY 20) -- GitLab