Andreas Tille pushed to branch master at Debian Med / terraphast


Commits:
7b906bf2 by Andreas Tille at 2026-10-17T19:54:39+02:00
Really commit the patches

- - - - -


2 changed files:

- + debian/patches/fix-c-api-test-corruption.patch
- + debian/patches/site-gen-root-species.patch


Changes:

=====================================
debian/patches/fix-c-api-test-corruption.patch
=====================================
@@ -0,0 +1,25 @@
+Description: Fix heap corruption in the c_api_error_num_partitions test
+ The test created a missing-data matrix with zero partitions and then
+ called setDataMatrix() on it.  initializeMissingData() allocates a
+ zero-sized matrix (new unsigned char[0]) for zero partitions, so the
+ setDataMatrix() calls wrote past the end of the allocation, corrupting
+ the heap.  terraceAnalysis() returns TERRACE_NUM_PARTITIONS_ERROR as soon
+ as numberOfPartitions < 2, before it reads the matrix, so the
+ setDataMatrix() calls are not needed at all; drop them.
+Author: Andreas Tille <[email protected]>
+Forwarded: not-needed
+Last-Update: 2026-10-17
+
+--- terraphast-0.1.0+dfsg.orig/test/c_api.cpp
++++ terraphast-0.1.0+dfsg/test/c_api.cpp
+@@ -112,10 +112,6 @@ TEST_CASE("c_api_error_num_partitions", "[c-api]") {
+       mpz_init(result);
+       const char* names[] = {"s1", "s2", "s3"};
+       auto data = initializeMissingData(3, 0, names);
+-      setDataMatrix(data, 0, 0, 1);
+-      setDataMatrix(data, 1, 0, 1);
+-      setDataMatrix(data, 2, 0, 1);
+-      setDataMatrix(data, 2, 1, 1);
+       REQUIRE(terraceAnalysis(data, "((s1,s2),s3)", TA_DETECT, nullptr, 
result) ==
+               TERRACE_NUM_PARTITIONS_ERROR);
+       freeMissingData(data);


=====================================
debian/patches/site-gen-root-species.patch
=====================================
@@ -0,0 +1,32 @@
+Description: site_gen: fix root species off-by-one generating invalid data
+ The root species index was drawn from the inclusive range 0..num_species,
+ so it could equal num_species, which is out of range.  In that case no
+ species was present in every site and a site column could end up without a
+ single 1.  Downstream tools (e.g. validated_run) require every site to
+ have at least one occurrence and abort with
+ "subtree_extraction.cpp:45: induced_lca: Assertion 'present(lca)' failed".
+ Draw the index from 0..num_species-1 so that one species is always present
+ in every site, and reject num_species == 0 to avoid an underflow.
+Author: Andreas Tille <[email protected]>
+Forwarded: https://github.com/amkozlov/terraphast-one
+Last-Update: 2026-10-17
+
+--- terraphast-0.1.0+dfsg.orig/tools/site_gen.cpp
++++ terraphast-0.1.0+dfsg/tools/site_gen.cpp
+@@ -12,11 +12,15 @@
+       const auto num_sites = std::stoul(argv[2]);
+       const auto prob = std::stod(argv[3]);
+ 
++      if (num_species == 0) {
++              return 1;
++      }
++
+       auto gen = std::default_random_engine{std::random_device{}()};
+       auto dist_p = std::uniform_real_distribution<double>{0.0, 1.0};
+ 
+       const auto root_species =
+-              std::uniform_int_distribution<unsigned long>{0u, 
num_species}(gen);
++              std::uniform_int_distribution<unsigned long>{0u, num_species - 
1}(gen);
+ 
+       std::cout << num_species << ' ' << num_sites << '\n';
+       for (auto i = 0ul; i < num_species; ++i) {



View it on GitLab: 
https://salsa.debian.org/med-team/terraphast/-/commit/7b906bf28e232e09a9c3aec6acd58451827e4be7

-- 
View it on GitLab: 
https://salsa.debian.org/med-team/terraphast/-/commit/7b906bf28e232e09a9c3aec6acd58451827e4be7
You're receiving this email because of your account on salsa.debian.org. Manage 
all notifications: https://salsa.debian.org/-/profile/notifications | Help: 
https://salsa.debian.org/help


_______________________________________________
debian-med-commit mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to