From 6391ff2fdf55c930e4bfb0bb8b88d22bcf408c37 Mon Sep 17 00:00:00 2001 From: Marco De Marco <demarco@oats.inaf.it> Date: Thu, 5 Dec 2013 16:34:16 +0100 Subject: [PATCH] Empty schema table user password check added --- src/DataExporter.cpp | 38 ++++++++++++++++++++++++++++++++++++-- src/DataExporter.h | 10 +++++----- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/DataExporter.cpp b/src/DataExporter.cpp index 9854fa0..27f7f44 100644 --- a/src/DataExporter.cpp +++ b/src/DataExporter.cpp @@ -610,7 +610,7 @@ void DataExporter::importExportedTables(std::vector<std::string>& exportedTables { std::size_t found; - if((found=exportedTables.at(i).find(' ')) == std::string::npos) + if((found=exportedTables.at(i).find(',')) == std::string::npos) { std::stringstream errorStream; errorStream << "ExportedTables property has invalid key at " @@ -619,8 +619,25 @@ void DataExporter::importExportedTables(std::vector<std::string>& exportedTables } std::string schema = exportedTables.at(i).substr(0, found); + + if(schema.empty()) + { + std::stringstream errorStream; + errorStream << "ExportedTables property has empty schema at " + << i << " position" << std::endl; + throw std::invalid_argument(errorStream.str()); + } + std::string table = exportedTables.at(i).substr(found+1, std::string::npos); + if(table.empty()) + { + std::stringstream errorStream; + errorStream << "ExportedTables property has empty table at " + << i << " position" << std::endl; + throw std::invalid_argument(errorStream.str()); + } + INFO_STREAM << "DataExporter::importExportedTables() schema " << schema << " table " << table << endl; @@ -641,7 +658,7 @@ void DataExporter::importAuthorisedUsers(std::vector<std::string>& authorisedUse { std::size_t found; - if((found=authorisedUsers.at(i).find(' ')) == std::string::npos) + if((found=authorisedUsers.at(i).find(',')) == std::string::npos) { std::stringstream errorStream; errorStream << "AuthorisedUsers property has invalid key at " @@ -650,8 +667,25 @@ void DataExporter::importAuthorisedUsers(std::vector<std::string>& authorisedUse } std::string user = authorisedUsers.at(i).substr(0, found); + + if(user.empty()) + { + std::stringstream errorStream; + errorStream << "AuthorisedUsers property has empty user at " + << i << " position" << std::endl; + throw std::invalid_argument(errorStream.str()); + } + std::string password = authorisedUsers.at(i).substr(found+1, std::string::npos); + if(password.empty()) + { + std::stringstream errorStream; + errorStream << "AuthorisedUsers property has empty password at " + << i << " position" << std::endl; + throw std::invalid_argument(errorStream.str()); + } + #ifdef VERBOSE_DEBUG INFO_STREAM << "DataExporter::importAuthorisedUsers() user " << user << " password " << password << endl; diff --git a/src/DataExporter.h b/src/DataExporter.h index bf46ce2..633a037 100644 --- a/src/DataExporter.h +++ b/src/DataExporter.h @@ -79,11 +79,11 @@ class DataExporter : public TANGO_BASE_CLASS //Max number of worker thread allowed static const unsigned int MAX_WORKER_NUMBER = 100; - //Max number of database connection allowed - static const unsigned int MAX_DB_CONNECTION_NUMBER = 100; - - //Max database port number allowed value - static const unsigned int MAX_DB_PORT = 65535; +// //Max number of database connection allowed +// static const unsigned int MAX_DB_CONNECTION_NUMBER = 100; +// +// //Max database port number allowed value +// static const unsigned int MAX_DB_PORT = 65535; /*----- PROTECTED REGION END -----*/ // DataExporter::Data Members -- GitLab