diff --git a/configfileparser.cpp b/configfileparser.cpp index ed42b99..3e72711 100644 --- a/configfileparser.cpp +++ b/configfileparser.cpp @@ -138,6 +138,12 @@ void ConfigFileParser::loadFile(bool test) if (line.empty()) continue; + // The regex matcher can be made to crash on very long lines, so we're protecting ourselves. + if (line.length() > 256) + { + throw ConfigFileException(formatString("Error at line %d in '%s': line suspiciouly long.", linenr, path.c_str())); + } + std::smatch matches; const bool blockStartMatch = std::regex_search(line, matches, block_regex_start); diff --git a/main.cpp b/main.cpp index 6b69b66..05c9c13 100644 --- a/main.cpp +++ b/main.cpp @@ -85,6 +85,12 @@ int main(int argc, char *argv[]) logger->logf(LOG_NOTICE, "Starting FlashMQ"); mainApp->start(); } + catch (ConfigFileException &ex) + { + // Not using the logger here, because we may have had all sorts of init errors while setting it up. + std::cerr << ex.what() << std::endl; + return 99; + } catch (std::exception &ex) { // Not using the logger here, because we may have had all sorts of init errors while setting it up.