diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-06-08 14:21:21 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-06-08 14:21:21 +0000 |
commit | 9095800a1750caf7e5d6951090e8f6c2a2facbc4 (patch) | |
tree | a3c42f09ec363d53821df13a6ad532813b46a68b /src/configreader.cpp | |
parent | 29fc8d035e313dd2bc9e3d2d89ff9b324d72f3b6 (diff) |
Check for invalid characters in keys, will catch config errors earlier and closer to the actual error line. Valid values in key names are [A-Za-z_]
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9863 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/configreader.cpp')
-rw-r--r-- | src/configreader.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index f8f17038b..bd4b4347d 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1492,7 +1492,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, FILE* &conf, const char* fil * If this finds an <include> then ParseLine can simply call * LoadConf() and load the included config into the same ConfigDataHash */ - if (!this->ParseLine(target, line, linenumber, errorstream)) + if (!this->ParseLine(target, filename, line, linenumber, errorstream)) return false; line.clear(); @@ -1522,7 +1522,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, FILE* &conf, const std::stri return this->LoadConf(target, conf, filename.c_str(), errorstream); } -bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long &linenumber, std::ostringstream &errorstream) +bool ServerConfig::ParseLine(ConfigDataHash &target, const std::string &filename, std::string &line, long &linenumber, std::ostringstream &errorstream) { std::string tagname; std::string current_key; @@ -1566,7 +1566,13 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long &li { if (*c != ' ') { - current_key += *c; + if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <='Z') || *c == '_') + current_key += *c; + else + { + errorstream << "Invalid character in key: '" << *c << "' in key '" << current_key << "' in filename: " << filename << ":" << linenumber << std::endl; + return false; + } } } else |