mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 04:29:57 +00:00
TUN-2748: Insecure randomness vulnerability in github.com/miekg/dns
This commit is contained in:
17
vendor/github.com/miekg/dns/msg_truncate.go
generated
vendored
17
vendor/github.com/miekg/dns/msg_truncate.go
generated
vendored
@@ -4,12 +4,17 @@ package dns
|
||||
// size by removing records that exceed the requested size.
|
||||
//
|
||||
// It will first check if the reply fits without compression and then with
|
||||
// compression. If it won't fit with compression, Scrub then walks the
|
||||
// compression. If it won't fit with compression, Truncate then walks the
|
||||
// record adding as many records as possible without exceeding the
|
||||
// requested buffer size.
|
||||
//
|
||||
// The TC bit will be set if any answer records were excluded from the
|
||||
// message. This indicates to that the client should retry over TCP.
|
||||
// The TC bit will be set if any records were excluded from the message.
|
||||
// This indicates to that the client should retry over TCP.
|
||||
//
|
||||
// According to RFC 2181, the TC bit should only be set if not all of the
|
||||
// "required" RRs can be included in the response. Unfortunately, we have
|
||||
// no way of knowing which RRs are required so we set the TC bit if any RR
|
||||
// had to be omitted from the response.
|
||||
//
|
||||
// The appropriate buffer size can be retrieved from the requests OPT
|
||||
// record, if present, and is transport specific otherwise. dns.MinMsgSize
|
||||
@@ -71,9 +76,9 @@ func (dns *Msg) Truncate(size int) {
|
||||
l, numExtra = truncateLoop(dns.Extra, size, l, compression)
|
||||
}
|
||||
|
||||
// According to RFC 2181, the TC bit should only be set if not all
|
||||
// of the answer RRs can be included in the response.
|
||||
dns.Truncated = len(dns.Answer) > numAnswer
|
||||
// See the function documentation for when we set this.
|
||||
dns.Truncated = len(dns.Answer) > numAnswer ||
|
||||
len(dns.Ns) > numNS || len(dns.Extra) > numExtra
|
||||
|
||||
dns.Answer = dns.Answer[:numAnswer]
|
||||
dns.Ns = dns.Ns[:numNS]
|
||||
|
Reference in New Issue
Block a user