Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Before adding an edge to the Boost graph, check it has not been added.
Apparently, this causes Boost graph adjacency list to misbehave.

Bug:#65
  • Loading branch information
ArthurSonzogni committed May 8, 2023
1 parent 01ac869 commit ee3e3ed
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Security:
- See CVE-2023-27390. Check there are no "self" message.
- See CVE-2023-31194. Do not add twice an edge in the graph. This caused Boost
algorithms to misbehave.

## Build
- Set MSVC_RUNTIME_LIBRARY to /MT for static builds
2 changes: 1 addition & 1 deletion src/input_output_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int main(int, const char**) {
std::string output_computed = translator->Translate(input, options);

if (output_computed == output) {
std::cout << " [PASS] " << test.path() << std::endl;
// std::cout << " [PASS] " << test.path() << std::endl;
} else {
std::cout << " [FAIL] " << test.path() << std::endl;
std::cout << "---[Output]------------------" << std::endl;
Expand Down
9 changes: 8 additions & 1 deletion src/translator/graph_planar/GraphPlanar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,15 @@ void GraphPlanar::Write() {

// Create a graph.
Graph graph(num_vertices);
for (auto& it : vertex)
for (auto& it : vertex) {
// Check if the edge already exists. Apparently, boost graph do not support
// it.
if (boost::edge(it.from, it.to, graph).second) {
continue;
}

add_edge(it.from, it.to, graph);
}
InitializeEdgeIndex(graph);

// Make it connected.
Expand Down
1 change: 1 addition & 0 deletions test/GraphPlanar/cve-2023-31194/input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A--B--C--D--E--F--D--C
18 changes: 18 additions & 0 deletions test/GraphPlanar/cve-2023-31194/output
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
┌─┐
│A│
└┬┘
┌┴┐
│B│
└┬┘
┌─────┐│
│ D ││
└┬─┬─┬┘│
│ │┌┴┐│
│ ││E││
│ │└┬┘│
│┌┴─┴┐│
││ F ││
│└───┘│
┌┴─────┴─┐
│ C │
└────────┘

0 comments on commit ee3e3ed

Please sign in to comment.