commit 25acbd1caafb357f0d96002d5779dcb683541cb1
parent a2b9612afb2687078ac1707e0d1896e690a49abb
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Thu, 25 Dec 2025 17:28:49 +0100
test_str_from_value.c: added an extra check
Must be backported
Diffstat:
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/tests/unit/test_str_from_value.c b/src/tests/unit/test_str_from_value.c
@@ -1693,6 +1693,23 @@ check_str_from_uint8_pad (void)
", while expecting 0.\n", t->val, (int) pad, (int) b_size,
(uintptr_t) rs);
}
+ else if (0 != memcmp (buf + b_size, "##########", sizeof(buf) - b_size
+ ))
+ {
+ t_failed++;
+ fprintf (stderr,
+ "FAILED: mhd_uint8_to_str_pad(%" PRIuFAST64 ", %d,"
+ " -> \"%.*s\", %d) returned %" PRIuPTR
+ " and touched memory outside provided buffer.\n"
+ "The tail of the buffer must be \"%.*s\", "
+ "but it is \"%.*s\".\n",
+ t->val, (int) pad, (int) rs, buf, (int) b_size,
+ (uintptr_t) rs,
+ (int) (sizeof(buf) - b_size),
+ "##########",
+ (int) (sizeof(buf) - b_size),
+ buf + b_size);
+ }
}
else
{