]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
tests: Fix for ASAN
authorPhil Sutter <phil@nwl.cc>
Wed, 27 Nov 2024 17:54:53 +0000 (18:54 +0100)
committerPhil Sutter <phil@nwl.cc>
Wed, 4 Dec 2024 14:44:05 +0000 (15:44 +0100)
The 'data' arrays in match and target expression tests were undersized
as they did not cover for the terminating NUL-char of the string used to
initialize them. When passing such array to strdup(), the latter reads
until after the defined array boundary.

Fixes: 93483364369d8 ("src: get rid of cached copies of x_tables.h and xt_LOG.h")
Signed-off-by: Phil Sutter <phil@nwl.cc>
tests/nft-expr_match-test.c
tests/nft-expr_target-test.c

index 53a8b849c484722b705ff3030249bd935d07c23a..bc9f6ac1b9ac87992088b920fa46e55bba9c68c0 100644 (file)
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
        char buf[4096];
        struct nftnl_expr_iter *iter_a, *iter_b;
        struct nftnl_expr *rule_a, *rule_b;
-       char data[16] = "0123456789abcdef";
+       char data[] = "0123456789abcdef";
 
        a = nftnl_rule_alloc();
        b = nftnl_rule_alloc();
index 89de945e58348ee684ebc2cd75af5ca55eb6e5c9..a483e7ac24dd8a85c079b8b0ed3069e2b691c297 100644 (file)
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
        char buf[4096];
        struct nftnl_expr_iter *iter_a, *iter_b;
        struct nftnl_expr *rule_a, *rule_b;
-       char data[16] = "0123456789abcdef";
+       char data[] = "0123456789abcdef";
 
        a = nftnl_rule_alloc();
        b = nftnl_rule_alloc();