From 4a527a2994587ec2b8b36ba9307fbef559c6e4ec Mon Sep 17 00:00:00 2001 From: Bjoern Sikora Date: Tue, 11 Aug 2009 09:55:53 +0200 Subject: [PATCH] Finally a string manipulating boost header was found ;-). Replaced own insecure to_lower with boost::algorithm::string::to_lower_copy. --- src/config.cpp | 23 ++++------------------- 1 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 458ed9a..af4308c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -25,6 +25,7 @@ #include #include #include +#include // Following boost macros are needed for serialization of derived classes through a base class pointer (Service *). BOOST_CLASS_EXPORT_GUID(ODS, "ODS") @@ -32,6 +33,7 @@ BOOST_CLASS_EXPORT_GUID(DHS, "DHS") namespace po = boost::program_options; namespace fs = boost::filesystem; +namespace ba = boost::algorithm; using namespace std; @@ -258,7 +260,7 @@ int Config::parse_cmd_line(int argc, char *argv[]) string login = VariablesMap["login"].as(); string password = VariablesMap["password"].as(); - protocol = to_lower(protocol); + protocol = ba::to_lower_copy(protocol); Service::Ptr service = create_service(protocol,host,login,password); if ( service ) @@ -332,23 +334,6 @@ Service::Ptr Config::create_service(const string &protocol,const string &hostnam /** - * Converts first ten characters of given string to lowercase. - * @param input String. - * @return String in lowercase. - */ -string Config::to_lower(string input) const -{ - int i = 0; - while ( input[i] && i<10 ) - { - input[i] = tolower(input[i]); - i++; - } - return input; -} - - -/** * Loads a service config file, invoked by load_config_from_files. * @param full_filename Filename of the service config file to load. * @return 0 if all is fine, -1 otherwise. @@ -375,7 +360,7 @@ int Config::load_service_config_file(const string& full_filename) string login = vm["login"].as(); string password = vm["password"].as(); - protocol = to_lower(protocol); + protocol = ba::to_lower_copy(protocol); Service::Ptr service = create_service(protocol,host,login,password); if ( service ) -- 1.7.1