Commit 233c373b authored by Michael Ott's avatar Michael Ott
Browse files

Fix NULL pointer and file name generation issues in SensorConfigImpl::findSensorCachePath()

parent 3c263553
...@@ -1946,18 +1946,24 @@ SCError SensorConfigImpl::findSensorCachePath() { ...@@ -1946,18 +1946,24 @@ SCError SensorConfigImpl::findSensorCachePath() {
return SC_OK; return SC_OK;
} }
// Retrieving name of the cluster (just once)
if(_clusterName == "" && getClusterName(_clusterName) != SC_OK) {
_clusterName = "";
return SC_UNKNOWNERROR;
}
// Create list of candidates to store the cache file at // Create list of candidates to store the cache file at
std::list<std::string> candidates; std::list<std::string> candidates;
if (libConfig.getTempDir().size() > 0) { if (libConfig.getTempDir().size() > 0) {
candidates.push_back(libConfig.getTempDir()); candidates.push_back(libConfig.getTempDir());
} }
std::string homeDir = getenv("HOME"); char* homeDir = getenv("HOME");
if (homeDir.size() > 0) { if (homeDir != nullptr) {
candidates.push_back(homeDir + "/.cache"); candidates.push_back(homeDir + std::string("/.cache"));
} }
std::string tempDir = getenv("TMPDIR"); char* tempDir = getenv("TMPDIR");
if (tempDir.size() > 0) { if (tempDir != nullptr) {
candidates.push_back(tempDir); candidates.push_back(std::string(tempDir));
} }
candidates.push_back(std::string("/tmp")); candidates.push_back(std::string("/tmp"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment