diff --git a/common/CheckPath.h b/common/CheckPath.h index e685b526..befcb130 100644 --- a/common/CheckPath.h +++ b/common/CheckPath.h @@ -8,7 +8,10 @@ #include "JFJochException.h" inline void CheckPath(const std::string &s) { - if (!s.empty() && s.front() == '/') + // CheckPath looks validates that s can be a valid file name + // (in practice with an added suffix, .e.g. _master.h5 or .tiff) + // It avoids paths going outside of a given directory + if (!s.empty() && (s.front() == '/' || s.back() != '/')) throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Path cannot start with slash"); if (s.size() >= 3 && s.substr(0,3) == "../")