Commit 100dc236 authored by François Grisez's avatar François Grisez

Rewrite FileConfigDumper::printHelp() in order to fix a buffer overflow

parent 7fcb3269
Pipeline #854 passed with stage
in 43 minutes and 32 seconds
......@@ -79,19 +79,17 @@ bool ConfigDumper::shouldDumpModule(const string &moduleName) const {
/* FILE CONFIG DUMPER */
ostream &FileConfigDumper::printHelp(ostream &os, const string &help, const string &comment_prefix) const {
const char *p = help.c_str();
const char *begin = p;
const char *origin = help.c_str();
for (; *p != 0; ++p) {
if ((p - begin > 60 && *p == ' ') || *p == '\n') {
os << comment_prefix << " " << help.substr(begin - origin, p - begin) << endl;
p++;
begin = p;
}
}
os << comment_prefix << " " << help.substr(begin - origin, p - origin) << endl;
return os;
auto it = help.cbegin();
auto begin = it;
for (; it != help.cend(); it++) {
if (((it - begin) > 60 && *it == ' ') || *it == '\n') {
os << comment_prefix << " " << string(begin, it) << endl;
begin = it + 1;
}
}
os << comment_prefix << " " << string(begin, it) << endl;
return os;
}
ostream &FileConfigDumper::dumpModuleValue(std::ostream &ostr, const ConfigValue *val, int level) const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment