Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#6337 from The-OpenROAD-Projec…
Browse files Browse the repository at this point in the history
…t-staging/secure-rsz-string-overflow-fix

fix for string overflow in repair_tie_fanout
  • Loading branch information
eder-matheus authored Dec 12, 2024
2 parents 8495fc8 + 702b98f commit 676f845
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/rsz/src/Resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ using sta::LoadPinIndexMap;
using sta::PinConnectedPinIterator;
using sta::Sdc;
using sta::SearchPredNonReg2;
using sta::stringPrint;
using sta::VertexIterator;
using sta::VertexOutEdgeIterator;

Expand Down Expand Up @@ -2422,7 +2421,8 @@ string Resizer::makeUniqueNetName()
string node_name;
Instance* top_inst = network_->topInstance();
do {
stringPrint(node_name, "net%d", unique_net_index_++);
// sta::stringPrint can lead to string overflow and fatal
node_name = fmt::format("net{}", unique_net_index_++);
} while (network_->findNet(top_inst, node_name.c_str()));
return node_name;
}
Expand All @@ -2443,10 +2443,12 @@ string Resizer::makeUniqueInstName(const char* base_name, bool underscore)
{
string inst_name;
do {
stringPrint(inst_name,
underscore ? "%s_%d" : "%s%d",
base_name,
unique_inst_index_++);
// sta::stringPrint can lead to string overflow and fatal
if (underscore) {
inst_name = fmt::format("{}_{}", base_name, unique_inst_index_++);
} else {
inst_name = fmt::format("{}{}", base_name, unique_inst_index_++);
}
} while (network_->findInstance(inst_name.c_str()));
return inst_name;
}
Expand Down

0 comments on commit 676f845

Please sign in to comment.