Skip to content

Commit

Permalink
Fix a (buffer overflow?) bug
Browse files Browse the repository at this point in the history
There was either a bug in instrumentor.cpp or there is still a bug in
ryml.
When processing the updated config file that includes C and Fortran,
ryml would throw a parse error and show text appended to the last line
of the config file (that's not actually there) in its error output.
  • Loading branch information
zbeekman committed Dec 15, 2024
1 parent 8599e95 commit e099a56
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/instrumentor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,9 +1126,16 @@ void instrumentor::instrument()
ryml::Tree yaml_tree;
if (FILE *config_file = fopen(configfile.c_str(), "r"))
{
std::string contents = file_get_contents(config_file);
yaml_tree = ryml::parse_in_arena(ryml::to_csubstr(contents));
ryml::emit(yaml_tree, yaml_tree.root_id(), config_file);
std::ifstream inputStream{configfile.c_str()};
if (!inputStream) {
llvm::errs() << "ERROR: Could not open configuration file " << configfile.c_str() << "\n";
std::exit(-3);
}
std::stringstream configStream;
configStream << inputStream.rdbuf();
// TODO handle errors if config yaml doesn't parse
yaml_tree = ryml::parse_in_arena(ryml::to_csubstr(configStream.str()));

fclose(config_file);
}
else
Expand Down

0 comments on commit e099a56

Please sign in to comment.