Silence warning when initialising compress

The string literal initialalising compressed was too big for the
array as it has an unwanted NUL terminator.  This is allowed for
in C for historical reasons but produces a warning with some
compilers.  Adjust the declaration to include the NUL and adjust
the users to pass in an adjusted size which excludes the NUL rather
than sizeof(compressed).
This commit is contained in:
Mark Andrews 2025-03-26 14:31:25 +11:00
parent 8ac453ab70
commit 6a6b6be824

View file

@ -219,11 +219,13 @@ ISC_RUN_TEST_IMPL(compression) {
"\003bar\003yyy\003foo\0"
"\003xxx\003bar\003foo";
unsigned char compressed[29] = "\x0E\xAD"
"\003yyy\003foo\0"
"\003bar\xc0\x02"
"\xc0\x0B"
"\003xxx\003bar\xc0\x06";
unsigned char compressed[] = "\x0E\xAD"
"\003yyy\003foo\0"
"\003bar\xc0\x02"
"\xc0\x0B"
"\003xxx\003bar\xc0\x06";
const size_t compressed_len = sizeof(compressed) - 1;
/*
* Only the second owner name is compressed.
*/
@ -284,8 +286,8 @@ ISC_RUN_TEST_IMPL(compression) {
dns_compress_setpermitted(&cctx, permitted);
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
compress_test(&name1, &name2, &name3, compressed, sizeof(compressed),
plain, sizeof(plain), &cctx, dctx, true);
compress_test(&name1, &name2, &name3, compressed, compressed_len, plain,
sizeof(plain), &cctx, dctx, true);
dns_compress_rollback(&cctx, 0);
dns_compress_invalidate(&cctx);
@ -345,8 +347,8 @@ ISC_RUN_TEST_IMPL(compression) {
dns_compress_setpermitted(&cctx, permitted);
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
compress_test(&name1, &name2, &name3, compressed, sizeof(compressed),
plain, sizeof(plain), &cctx, dctx, false);
compress_test(&name1, &name2, &name3, compressed, compressed_len, plain,
sizeof(plain), &cctx, dctx, false);
dns_compress_rollback(&cctx, 0);
dns_compress_invalidate(&cctx);