diff --git a/continuousintegration/build_deploy.sh b/continuousintegration/build_deploy.sh index 973f80e33c67450bafea5c44e8d2c4d838faaae1..ed96de72f4cc10b1f6fbfbbf2e1d44af58becf1b 100755 --- a/continuousintegration/build_deploy.sh +++ b/continuousintegration/build_deploy.sh @@ -370,7 +370,7 @@ build_deploy() { fi if [[ ${enable_address_sanitizer} = true ]]; then - build_rpm_flags+=" --address-sanitizer" + build_rpm_flags+=" --enable-address-sanitizer" fi print_header "BUILDING RPMS" diff --git a/mediachanger/librmc/Cdomainname.cpp b/mediachanger/librmc/Cdomainname.cpp index d69d8f2c3c1a41e1719b601399305f66337958e7..639c4bb4712188efcbca5138d8b29d7efdc7efa6 100644 --- a/mediachanger/librmc/Cdomainname.cpp +++ b/mediachanger/librmc/Cdomainname.cpp @@ -51,9 +51,14 @@ int Cdomainname(char* name, int namelen) { if (*p != '\0') { *(p + strlen(p) - 1) = '\0'; } - name[namelen] = '\0'; - strncpy(name, p, namelen + 1); - if (name[namelen] != '\0') { + if (namelen == 0) { + serrno = EINVAL; + return -1; + } + size_t maxcopy = namelen - 1; + name[maxcopy] = '\0'; + strncpy(name, p, maxcopy); + if (name[maxcopy] != '\0') { serrno = EINVAL; return -1; } diff --git a/objectstore/Backend.hpp b/objectstore/Backend.hpp index ccd6928619436a6ede37a7d33eefca73187a1a7c..8c6a89871c068990e843a60e09ccb2d994a1a250 100644 --- a/objectstore/Backend.hpp +++ b/objectstore/Backend.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "common/exception/Exception.hpp" @@ -246,7 +247,7 @@ class Backend { * Returns a type specific representation of the parameters * @return pointer to the newly created representation. */ - virtual Parameters * getParams() = 0; + virtual std::unique_ptr getParams() = 0; /** * Return the name of the class. Mostly usefull in tests diff --git a/objectstore/BackendRados.cpp b/objectstore/BackendRados.cpp index a87fb635962ecab67a0e74c809088db98a9bda6d..11dd1685a02c31868a79978865e75c69a568eb26 100644 --- a/objectstore/BackendRados.cpp +++ b/objectstore/BackendRados.cpp @@ -1087,12 +1087,12 @@ std::string BackendRados::Parameters::toURL() { } -BackendRados::Parameters* BackendRados::getParams() { - std::unique_ptr ret(new Parameters); +std::unique_ptr BackendRados::getParams() { + auto ret = std::make_unique(); ret->m_pool = m_pool; ret->m_userId = m_user; ret->m_namespace = m_namespace; - return ret.release(); + return ret; } } // namespace cta::objectstore diff --git a/objectstore/BackendRados.hpp b/objectstore/BackendRados.hpp index f4fb12585937ca08c2fa7af47d4071dbaf2b5965..df7dbb8a51591958cdb9fab0afc3e9835f7d6476 100644 --- a/objectstore/BackendRados.hpp +++ b/objectstore/BackendRados.hpp @@ -347,7 +347,7 @@ public: std::string m_namespace; }; - Parameters * getParams() override; + std::unique_ptr getParams() override; std::string typeName() override { return "cta::objectstore::BackendRados"; diff --git a/objectstore/BackendVFS.cpp b/objectstore/BackendVFS.cpp index 922b772fe3a4936eaa433bc55aecf069b25346d3..d567ee16ea9095b2ae8ac4addf0199576b95180f 100644 --- a/objectstore/BackendVFS.cpp +++ b/objectstore/BackendVFS.cpp @@ -228,10 +228,10 @@ std::list BackendVFS::list() { return ret; } -BackendVFS::Parameters* BackendVFS::getParams() { - std::unique_ptr ret(new Parameters); +std::unique_ptr BackendVFS::getParams() { + auto ret = std::make_unique(); ret->m_path = m_root; - return ret.release(); + return ret; } void BackendVFS::ScopedLock::release() { diff --git a/objectstore/BackendVFS.hpp b/objectstore/BackendVFS.hpp index f600ac0c812fbe7163253ce3ea9273c5bd33ea22..907c3d23fc9bb3079265ec6e1237ff411ab3aa26 100644 --- a/objectstore/BackendVFS.hpp +++ b/objectstore/BackendVFS.hpp @@ -200,7 +200,7 @@ class BackendVFS: public Backend { std::string m_path; }; - Parameters * getParams() override; + std::unique_ptr getParams() override; std::string typeName() override { diff --git a/objectstore/cta-objectstore-collect-orphaned-object.cpp b/objectstore/cta-objectstore-collect-orphaned-object.cpp index 8bdc1fada2b8e0c62d9344dc308dcfb90c02244b..761a599ec991d0a069f73d1405c13bdefd166b22 100644 --- a/objectstore/cta-objectstore-collect-orphaned-object.cpp +++ b/objectstore/cta-objectstore-collect-orphaned-object.cpp @@ -77,7 +77,8 @@ int main(int argc, char ** argv) { try { dynamic_cast(*be).noDeleteOnExit(); } catch (std::bad_cast &){} - std::cout << "Object store path: " << be->getParams()->toURL() << std::endl; + auto params = be->getParams(); + std::cout << "Object store path: " << params->toURL() << std::endl; // Try and open the object. cta::objectstore::GenericObject go(objectName, *be); cta::objectstore::ScopedExclusiveLock gol(go); diff --git a/objectstore/cta-objectstore-create-missing-repack-index.cpp b/objectstore/cta-objectstore-create-missing-repack-index.cpp index 1f02300fb7ef7380c4796e706c447b4a3d7770ba..75d28bf9887f6c84142de6bac1e027b3c28b750b 100644 --- a/objectstore/cta-objectstore-create-missing-repack-index.cpp +++ b/objectstore/cta-objectstore-create-missing-repack-index.cpp @@ -16,7 +16,7 @@ */ /** - * This program will make sure every queue listed in the root entry does exist and + * This program will make sure every queue listed in the root entry does exist and * will remove reference for the ones that do not. This utility was created to quickly * unblock tape servers after changing the ArchiveQueue schema during development. */ @@ -55,7 +55,8 @@ int main(int argc, char ** argv) { try { dynamic_cast(*be).noDeleteOnExit(); } catch (std::bad_cast &){} - std::cout << "Object store path: " << be->getParams()->toURL() << std::endl; + auto params = be->getParams(); + std::cout << "Object store path: " << params->toURL() << std::endl; // Open the root entry RW std::cout << "Creating AgentReference for the creation of the repack index" << std::endl; cta::objectstore::AgentReference agr("cta-objectstore-create-missing-repack-index", logger); @@ -75,7 +76,7 @@ int main(int argc, char ** argv) { std::cout << "Trying to insert repack index" << std::endl; std::string repackIndexAddress = re.addOrGetRepackIndexAndCommit(agr); std::cout << "Repack index created. Address = " << repackIndexAddress << std::endl; - + } catch (const cta::objectstore::RootEntry::DriveRegisterNotEmpty &ex ) { std::cout << "Could not remove the already existing repack index, errorMsg = " << ex.getMessageValue(); return 1; diff --git a/objectstore/cta-objectstore-dereference-removed-queues.cpp b/objectstore/cta-objectstore-dereference-removed-queues.cpp index 9aa2acc36ab97dfba8897b805ee906b180b9acf0..5853ef4163350821fd5642aa4c42ef5f331523cd 100644 --- a/objectstore/cta-objectstore-dereference-removed-queues.cpp +++ b/objectstore/cta-objectstore-dereference-removed-queues.cpp @@ -102,7 +102,8 @@ int main(int argc, char ** argv) { try { dynamic_cast(*be).noDeleteOnExit(); } catch (std::bad_cast &){} - std::cout << "Object store path: " << be->getParams()->toURL() << std::endl; + auto params = be->getParams(); + std::cout << "Object store path: " << params->toURL() << std::endl; // Open the root entry RW cta::objectstore::RootEntry re(*be); cta::objectstore::ScopedExclusiveLock rel(re); diff --git a/objectstore/cta-objectstore-dump-object.cpp b/objectstore/cta-objectstore-dump-object.cpp index e9ddaa3b3a5421bd491b57783ea6634ef3fa54f4..eb0717b001ed63740820953ff795ad027818cc15 100644 --- a/objectstore/cta-objectstore-dump-object.cpp +++ b/objectstore/cta-objectstore-dump-object.cpp @@ -102,7 +102,8 @@ int main(int argc, char ** argv) { } catch (std::bad_cast &){} cta::objectstore::GenericObject ge(objectName, *be); ge.fetchNoLock(); - std::string objectStorePath = be->getParams()->toURL(); + auto params = be->getParams(); + std::string objectStorePath = params->toURL(); if (dump_object_body_only) { cta::utils::json::object::JSONCObject jObject; jObject.buildFromJSON(ge.dump().second); @@ -120,7 +121,7 @@ int main(int argc, char ** argv) { jObject.buildFromJSON(oss.str()); std::cout << jObject.getJSONPretty() << std::endl; } else { - std::cout << "Object store path: " << be->getParams()->toURL() << std::endl; + std::cout << "Object store path: " << params->toURL() << std::endl; std::cout << "Object name: " << objectName << std::endl; std::cout << "Header dump:" << std::endl; std::cout << headerDump; diff --git a/objectstore/cta-objectstore-initialize.cpp b/objectstore/cta-objectstore-initialize.cpp index 0c9a57b3e1c40b1f6cf61a27818365c9309f3780..d9bf9ec54a1d9db5eddc578b5abb51429d4f17e5 100644 --- a/objectstore/cta-objectstore-initialize.cpp +++ b/objectstore/cta-objectstore-initialize.cpp @@ -71,7 +71,8 @@ int main(int argc, char ** argv) { ag.removeAndUnregisterSelf(lc); } rel.release(); - std::cout << "New object store path: " << be->getParams()->toURL() << std::endl; + auto params = be->getParams(); + std::cout << "New object store path: " << params->toURL() << std::endl; return EXIT_SUCCESS; } catch (std::exception & e) { std::cerr << "Failed to initialise the root entry in a new " << ((be != nullptr) ? be->typeName() : "no-backend") << " objectstore" diff --git a/objectstore/cta-objectstore-list.cpp b/objectstore/cta-objectstore-list.cpp index 5b2e015734cd2039395a1da368bb0d580bd764b8..67006a8a02739f37a1fa2d2210c562a8e4611904 100644 --- a/objectstore/cta-objectstore-list.cpp +++ b/objectstore/cta-objectstore-list.cpp @@ -50,7 +50,8 @@ int main(int argc, char ** argv) { dynamic_cast(*be).noDeleteOnExit(); } catch (std::bad_cast &){} // If not, nevermind. - std::cout << "Object store path: " << be->getParams()->toURL() << std::endl; + auto params = be->getParams(); + std::cout << "Object store path: " << params->toURL() << std::endl; auto l = be->list(); for (auto o=l.begin(); o!=l.end(); o++) { std::cout << *o << std::endl;