Skip to content

Commit dec9fe7

Browse files
fortunagopherbot
authored andcommitted
dns/dnsmessage: update SVCB packing to prohibit name compression
This commit updates the dns/dnsmessage package to correctly handle SVCB record packing by prohibiting name compression for the Target field. It turns out the compression of names in RDATA is prohibited (see https://datatracker.ietf.org/doc/html/rfc3597#section-4), except for well-known record types (those defined in https://datatracker.ietf.org/doc/html/rfc1035). The SVCB RFC actually explicitly calls that out (https://datatracker.ietf.org/doc/html/rfc9460#section-2.2), so it was an oversight in my part in https://go.dev/cl/710736. Updates golang/go#43790 Change-Id: I287b034c9e01b49264e07e23293bacd830ab1832 GitHub-Last-Rev: 1d16664 GitHub-Pull-Request: #242 Reviewed-on: https://go-review.googlesource.com/c/net/+/713900 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Vinicius Fortuna <fortuna@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Sean Liao <sean@liao.dev>
1 parent 9be1ff2 commit dec9fe7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

dns/dnsmessage/svcb.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,14 @@ func (k SVCParamKey) GoString() string {
160160
return printUint16(uint16(k))
161161
}
162162

163-
func (r *SVCBResource) pack(msg []byte, compression map[string]uint16, compressionOff int) ([]byte, error) {
163+
func (r *SVCBResource) pack(msg []byte, _ map[string]uint16, _ int) ([]byte, error) {
164164
oldMsg := msg
165165
msg = packUint16(msg, r.Priority)
166-
msg, err := r.Target.pack(msg, compression, compressionOff)
166+
// https://datatracker.ietf.org/doc/html/rfc3597#section-4 prohibits name
167+
// compression for RR types that are not "well-known".
168+
// https://datatracker.ietf.org/doc/html/rfc9460#section-2.2 explicitly states that
169+
// compression of the Target is prohibited, following RFC 3597.
170+
msg, err := r.Target.pack(msg, nil, 0)
167171
if err != nil {
168172
return oldMsg, &nestedError{"SVCBResource.Target", err}
169173
}

0 commit comments

Comments
 (0)