summaryrefslogtreecommitdiff
path: root/tests/unit/mempool_safeguards_test.c
diff options
context:
space:
mode:
authorDenys Fedoryshchenko <denys.f@collabora.com>2026-09-07 22:08:04 +0300
committerDenys Fedoryshchenko <denys.f@collabora.com>2026-09-07 22:08:04 +0300
commit06aa0ef737d6993fd18e7db1bc8fc35601079505 (patch)
tree9798c36490704622952d7a2aabf8262403202f3d /tests/unit/mempool_safeguards_test.c
parent7cf7432017bf5386e8b8907aa3abb9e6c45f12bb (diff)
downloadaccel-ppp-06aa0ef737d6993fd18e7db1bc8fc35601079505.tar.gz
accel-ppp-06aa0ef737d6993fd18e7db1bc8fc35601079505.zip
tests: cover additional safeguards and document PR 40 comparison
Add standalone regression coverage for DHCPv6 parsing/replies, RADIUS response authentication/signing, VRF/CoA name bounds, LCP Echo MTU and pool reuse. Document all 20 reference commits, upstream coverage, author credits, adaptations and validation limits. Validation: default userspace Debug build; five standalone suites with ASan/UBSan (LCP UBSan only), including LeakSanitizer for ASan tests; existing IPv6 DNS test; git diff --check. All passed. Baseline duplicate Rapid-Commit and forged Access-Accept assertions fail as expected. Full privileged session integration was not run.
Diffstat (limited to 'tests/unit/mempool_safeguards_test.c')
-rw-r--r--tests/unit/mempool_safeguards_test.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/unit/mempool_safeguards_test.c b/tests/unit/mempool_safeguards_test.c
new file mode 100644
index 00000000..b0c6a3dc
--- /dev/null
+++ b/tests/unit/mempool_safeguards_test.c
@@ -0,0 +1,38 @@
+/* Pool reuse must not expose the previous object's payload. */
+#include <assert.h>
+#include <pthread.h>
+#include "triton.h"
+#undef __init
+#define __init
+#include "../../accel-pppd/triton/mempool.c"
+
+void triton_log_error(const char *fmt, ...) {}
+void triton_stat_mempool_allocated_add(uint64_t v) {}
+void triton_stat_mempool_allocated_sub(uint64_t v) {}
+void triton_stat_mempool_available_add(uint64_t v) {}
+void triton_stat_mempool_available_sub(uint64_t v) {}
+
+int main(void)
+{
+ mempool_t *pool;
+ unsigned char *p, *q;
+ int i;
+
+ spinlock_init(&pools_lock);
+ pool = mempool_create(128);
+ p = mempool_alloc(pool);
+ assert(p);
+ memset(p, 0xa5, 128);
+ mempool_free(p);
+ q = mempool_alloc(pool);
+ assert(q == p);
+ for (i = 0; i < 128; i++)
+ assert(!q[i]);
+ memset(q, 0x5a, 128);
+ mempool_free(q);
+ mempool_clean();
+ list_del(&((struct _mempool_t *)pool)->entry);
+ free(pool);
+ puts("Mempool safeguards: PASS");
+ return 0;
+}