libqaeda

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 4b75fc2392072fad400f89fb76615f2cdb568807
parent 5f85b13c7bd8588e90b8acbafff06ae65c60a85c
Author: lash <dev@holbrook.no>
Date:   Sat, 22 Mar 2025 22:40:11 +0000

Test get and set overflow

Diffstat:
Msrc/lq/config.c | 4++--
Msrc/test/test_config.c | 3+++
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lq/config.c b/src/lq/config.c @@ -83,7 +83,7 @@ int lq_config_set(int k, void *v) { void *p; size_t l; - if (k > config.last) { + if (k >= config.last) { return ERR_OVERFLOW; } @@ -116,7 +116,7 @@ int lq_config_set(int k, void *v) { } int lq_config_get(int k, void **r) { - if (k > config.last) { + if (k >= config.last) { return ERR_OVERFLOW; } diff --git a/src/test/test_config.c b/src/test/test_config.c @@ -51,6 +51,9 @@ START_TEST(check_set_get) { ck_assert_int_eq(r, ERR_OK); ck_assert_str_eq(p, "foobarbaz"); + r = lq_config_set(3, &v); + ck_assert_int_eq(r, ERR_OVERFLOW); + r = lq_config_get(3, (void**)&p); ck_assert_int_eq(r, ERR_OVERFLOW);