[9.20] fix: usr: DSYNC record incorrectly used two octets for the Scheme Field

When creating the `DSYNC` record from a structure, `uint16_tobuffer` was used instead of `uint8_tobuffer` when adding the scheme, causing a `DSYNC` record that was one octet too long. This has been fixed.

Closes #5711

Backport of MR !11477

Merge branch 'backport-5711-dsync_fromstruct-produces-an-invalid-record-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11483
This commit is contained in:
Mark Andrews 2026-01-24 02:19:23 +11:00
commit bd9f73c705
2 changed files with 12 additions and 11 deletions

View file

@ -237,7 +237,7 @@ fromstruct_dsync(ARGS_FROMSTRUCT) {
UNUSED(rdclass);
RETERR(uint16_tobuffer(dsync->type, target));
RETERR(uint16_tobuffer(dsync->scheme, target));
RETERR(uint8_tobuffer(dsync->scheme, target));
RETERR(uint16_tobuffer(dsync->port, target));
dns_name_toregion(&dsync->target, &region);
return isc_buffer_copyregion(target, &region);

View file

@ -1788,43 +1788,43 @@ ISC_RUN_TEST_IMPL(dsync) {
/*
* Known type and known scheme.
*/
TEXT_VALID("CDS NOTIFY 0 example.com"),
TEXT_VALID("CDS NOTIFY 0 example.com."),
/*
* Known type and unknown scheme.
*/
TEXT_VALID("CDS 3 0 example.com"),
TEXT_VALID("CDS 3 0 example.com."),
/*
* Unknown type and known scheme.
*/
TEXT_VALID("TYPE1000 NOTIFY 0 example.com"),
TEXT_VALID("TYPE1000 NOTIFY 0 example.com."),
/*
* Unknown type and unknown scheme.
*/
TEXT_VALID("TYPE1000 3 0 example.com"),
TEXT_VALID("TYPE1000 3 0 example.com."),
/*
* Unknown type and unknown scheme, max port.
*/
TEXT_VALID("TYPE1000 3 65535 example.com"),
TEXT_VALID("TYPE1000 3 65535 example.com."),
/*
* Unknown type and max scheme, max port.
*/
TEXT_VALID("TYPE64000 255 65535 example.com"),
TEXT_VALID("TYPE64000 255 65535 example.com."),
/*
* Invalid type and max scheme, max port.
*/
TEXT_INVALID("INVALID 255 65536 example.com"),
TEXT_INVALID("INVALID 255 65536 example.com."),
/*
* Unknown type and too big scheme, max port.
*/
TEXT_INVALID("TYPE1000 256 65536 example.com"),
TEXT_INVALID("TYPE1000 256 65536 example.com."),
/*
* Unknown type and unknown scheme, port too big.
*/
TEXT_INVALID("TYPE1000 3 65536 example.com"),
TEXT_INVALID("TYPE1000 3 65536 example.com."),
/*
* Unknown type and bad scheme, max port.
*/
TEXT_INVALID("TYPE1000 UNKNOWN 65535 example.com"),
TEXT_INVALID("TYPE1000 UNKNOWN 65535 example.com."),
/*
* Sentinel.
*/
@ -3331,6 +3331,7 @@ ISC_TEST_ENTRY(csync)
ISC_TEST_ENTRY(dnskey)
ISC_TEST_ENTRY(doa)
ISC_TEST_ENTRY(ds)
ISC_TEST_ENTRY(dsync)
ISC_TEST_ENTRY(eid)
ISC_TEST_ENTRY(hip)
ISC_TEST_ENTRY(https_svcb)