From: Magnus Jacobsson Date: Mon, 18 Jul 2022 13:02:59 +0000 (+0200) Subject: twopigen: layout: fix heap-buffer-overflow by storing dimension in root graph X-Git-Tag: 5.0.1~31^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=434ff46f2486762b2cea33439884bf2151110dfe;p=graphviz twopigen: layout: fix heap-buffer-overflow by storing dimension in root graph The layout allocates memory based on the dimension of the root graph, but since the dimension was stored in the subgraph and the dimension in the root graph defaulted to zero, too little memory was allocated. An alternative solution would have been to use the dimension of the subgraph, but this had other implications and the chosen solution is the same as what the other two layout engines supporting the dim attribute (neato and sfdp) use. Twopi always uses two dimensions. This fixes the last memory issue detected by ASan in the test_subgraph_layout test, which now runs without failures. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 98f76116f..134809f67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Segmentation fault when running test example neatopack.c #1800 - Memory leak in dot when using clusters - Memory leak in patchwork when using clusters +- Subgraph layout and rendering ## [5.0.0] – 2022-07-07 diff --git a/lib/twopigen/twopiinit.c b/lib/twopigen/twopiinit.c index 16eecda3b..705ca4834 100644 --- a/lib/twopigen/twopiinit.c +++ b/lib/twopigen/twopiinit.c @@ -53,7 +53,7 @@ void twopi_init_graph(graph_t * g) { setEdgeType (g, EDGETYPE_LINE); /* GD_ndim(g) = late_int(g,agfindgraphattr(g,"dim"),2,2); */ - Ndim = GD_ndim(g)=2; /* The algorithm only makes sense in 2D */ + Ndim = GD_ndim(agroot(g)) = 2; /* The algorithm only makes sense in 2D */ twopi_init_node_edge(g); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3aa2d52fa..2ac89859c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -76,5 +76,4 @@ CREATE_TEST(GVLayout_render) CREATE_TEST(neatopack) CREATE_TEST(simple) CREATE_TEST(subgraph_layout) -set_tests_properties(test_subgraph_layout PROPERTIES WILL_FAIL true) CREATE_TEST(subgraphs)