]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
test_journal: correct potential for truncation in snprintf
authorJan Doskočil <jan.doskocil@nic.cz>
Fri, 16 Aug 2024 09:08:39 +0000 (11:08 +0200)
committerJan Doskočil <jan.doskocil@nic.cz>
Fri, 16 Aug 2024 09:09:30 +0000 (11:09 +0200)
fmt string is "i%d" - theoretically if the argument was eg INT_MIN this
could've been 13 chars long, which is why gcc threw a warning

tests/knot/test_journal.c

index 748ab02d02622269801a1596fd51e87c2621a612..750fad871772cee305b908c231bf20df4b66ed51 100644 (file)
@@ -557,7 +557,7 @@ static knot_dname_t *tm_owner(const char *prefix, const knot_dname_t *apex)
 
 static knot_dname_t *tm_owner_int(int x, const knot_dname_t *apex)
 {
-       char buf[12] = { 0 };
+       char buf[13] = { 0 };
        (void)snprintf(buf, sizeof(buf), "i%d", x);
        return tm_owner(buf, apex);
 }