Update miekg/dns

This commit is contained in:
Frank Denis 2023-03-29 22:00:24 +09:00
parent a47f7fe750
commit cf7d60a704
9 changed files with 36 additions and 39 deletions

2
go.mod
View file

@ -18,7 +18,7 @@ require (
github.com/jedisct1/xsecretbox v0.0.0-20230211185120-2025cdbb9f0f github.com/jedisct1/xsecretbox v0.0.0-20230211185120-2025cdbb9f0f
github.com/k-sone/critbitgo v1.4.0 github.com/k-sone/critbitgo v1.4.0
github.com/kardianos/service v1.2.2 github.com/kardianos/service v1.2.2
github.com/miekg/dns v1.1.52 github.com/miekg/dns v1.1.53
github.com/powerman/check v1.7.0 github.com/powerman/check v1.7.0
github.com/quic-go/quic-go v0.33.0 github.com/quic-go/quic-go v0.33.0
golang.org/x/crypto v0.7.0 golang.org/x/crypto v0.7.0

4
go.sum
View file

@ -54,8 +54,8 @@ github.com/k-sone/critbitgo v1.4.0 h1:l71cTyBGeh6X5ATh6Fibgw3+rtNT80BA0uNNWgkPrb
github.com/k-sone/critbitgo v1.4.0/go.mod h1:7E6pyoyADnFxlUBEKcnfS49b7SUAQGMK+OAp/UQvo0s= github.com/k-sone/critbitgo v1.4.0/go.mod h1:7E6pyoyADnFxlUBEKcnfS49b7SUAQGMK+OAp/UQvo0s=
github.com/kardianos/service v1.2.2 h1:ZvePhAHfvo0A7Mftk/tEzqEZ7Q4lgnR8sGz4xu1YX60= github.com/kardianos/service v1.2.2 h1:ZvePhAHfvo0A7Mftk/tEzqEZ7Q4lgnR8sGz4xu1YX60=
github.com/kardianos/service v1.2.2/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM= github.com/kardianos/service v1.2.2/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM=
github.com/miekg/dns v1.1.52 h1:Bmlc/qsNNULOe6bpXcUTsuOajd0DzRHwup6D9k1An0c= github.com/miekg/dns v1.1.53 h1:ZBkuHr5dxHtB1caEOlZTLPo7D3L3TWckgUUs/RHfDxw=
github.com/miekg/dns v1.1.52/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/miekg/dns v1.1.53/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY=
github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI= github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI=
github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk=
github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q=

View file

@ -78,7 +78,7 @@ A not-so-up-to-date-list-that-may-be-actually-current:
* https://fleetdeck.io/ * https://fleetdeck.io/
* https://github.com/markdingo/autoreverse * https://github.com/markdingo/autoreverse
* https://github.com/slackhq/nebula * https://github.com/slackhq/nebula
* https://github.com/dnschecktool/dow-proxy * https://addr.tools/
* https://dnscheck.tools/ * https://dnscheck.tools/
* https://github.com/egbakou/domainverifier * https://github.com/egbakou/domainverifier

View file

@ -208,7 +208,7 @@ func IsDomainName(s string) (labels int, ok bool) {
} }
// check for \DDD // check for \DDD
if i+3 < len(s) && isDigit(s[i+1]) && isDigit(s[i+2]) && isDigit(s[i+3]) { if isDDD(s[i+1:]) {
i += 3 i += 3
begin += 3 begin += 3
} else { } else {

View file

@ -128,10 +128,6 @@ type dnskeyWireFmt struct {
/* Nothing is left out */ /* Nothing is left out */
} }
func divRoundUp(a, b int) int {
return (a + b - 1) / b
}
// KeyTag calculates the keytag (or key-id) of the DNSKEY. // KeyTag calculates the keytag (or key-id) of the DNSKEY.
func (k *DNSKEY) KeyTag() uint16 { func (k *DNSKEY) KeyTag() uint16 {
if k == nil { if k == nil {
@ -417,11 +413,11 @@ func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error {
return err return err
} }
sigbuf := rr.sigBuf() // Get the binary signature data sigbuf := rr.sigBuf() // Get the binary signature data
if rr.Algorithm == PRIVATEDNS { // PRIVATEOID // TODO(miek)
// TODO(miek) // remove the domain name and assume its ours?
// remove the domain name and assume its ours? // if rr.Algorithm == PRIVATEDNS { // PRIVATEOID
} // }
h, cryptohash, err := hashFromAlgorithm(rr.Algorithm) h, cryptohash, err := hashFromAlgorithm(rr.Algorithm)
if err != nil { if err != nil {

29
vendor/github.com/miekg/dns/msg.go generated vendored
View file

@ -252,7 +252,7 @@ loop:
} }
// check for \DDD // check for \DDD
if i+3 < ls && isDigit(bs[i+1]) && isDigit(bs[i+2]) && isDigit(bs[i+3]) { if isDDD(bs[i+1:]) {
bs[i] = dddToByte(bs[i+1:]) bs[i] = dddToByte(bs[i+1:])
copy(bs[i+1:ls-3], bs[i+4:]) copy(bs[i+1:ls-3], bs[i+4:])
ls -= 3 ls -= 3
@ -482,8 +482,8 @@ func packTxtString(s string, msg []byte, offset int) (int, error) {
break break
} }
// check for \DDD // check for \DDD
if i+2 < len(s) && isDigit(s[i]) && isDigit(s[i+1]) && isDigit(s[i+2]) { if isDDD(s[i:]) {
msg[offset] = dddStringToByte(s[i:]) msg[offset] = dddToByte(s[i:])
i += 2 i += 2
} else { } else {
msg[offset] = s[i] msg[offset] = s[i]
@ -517,7 +517,7 @@ func packOctetString(s string, msg []byte, offset int, tmp []byte) (int, error)
break break
} }
// check for \DDD // check for \DDD
if i+2 < len(bs) && isDigit(bs[i]) && isDigit(bs[i+1]) && isDigit(bs[i+2]) { if isDDD(bs[i:]) {
msg[offset] = dddToByte(bs[i:]) msg[offset] = dddToByte(bs[i:])
i += 2 i += 2
} else { } else {
@ -546,12 +546,11 @@ func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) {
// Helpers for dealing with escaped bytes // Helpers for dealing with escaped bytes
func isDigit(b byte) bool { return b >= '0' && b <= '9' } func isDigit(b byte) bool { return b >= '0' && b <= '9' }
func dddToByte(s []byte) byte { func isDDD[T ~[]byte | ~string](s T) bool {
_ = s[2] // bounds check hint to compiler; see golang.org/issue/14808 return len(s) >= 3 && isDigit(s[0]) && isDigit(s[1]) && isDigit(s[2])
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
} }
func dddStringToByte(s string) byte { func dddToByte[T ~[]byte | ~string](s T) byte {
_ = s[2] // bounds check hint to compiler; see golang.org/issue/14808 _ = s[2] // bounds check hint to compiler; see golang.org/issue/14808
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0')) return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
} }
@ -861,7 +860,7 @@ func (dns *Msg) unpack(dh Header, msg []byte, off int) (err error) {
// The header counts might have been wrong so we need to update it // The header counts might have been wrong so we need to update it
dh.Nscount = uint16(len(dns.Ns)) dh.Nscount = uint16(len(dns.Ns))
if err == nil { if err == nil {
dns.Extra, off, err = unpackRRslice(int(dh.Arcount), msg, off) dns.Extra, _, err = unpackRRslice(int(dh.Arcount), msg, off)
} }
// The header counts might have been wrong so we need to update it // The header counts might have been wrong so we need to update it
dh.Arcount = uint16(len(dns.Extra)) dh.Arcount = uint16(len(dns.Extra))
@ -871,11 +870,11 @@ func (dns *Msg) unpack(dh Header, msg []byte, off int) (err error) {
dns.Rcode |= opt.ExtendedRcode() dns.Rcode |= opt.ExtendedRcode()
} }
if off != len(msg) { // TODO(miek) make this an error?
// TODO(miek) make this an error? // use PackOpt to let people tell how detailed the error reporting should be?
// use PackOpt to let people tell how detailed the error reporting should be? // if off != len(msg) {
// println("dns: extra bytes in dns packet", off, "<", len(msg)) // // println("dns: extra bytes in dns packet", off, "<", len(msg))
} // }
return err return err
} }
@ -1019,7 +1018,7 @@ func escapedNameLen(s string) int {
continue continue
} }
if i+3 < len(s) && isDigit(s[i+1]) && isDigit(s[i+2]) && isDigit(s[i+3]) { if isDDD(s[i+1:]) {
nameLen -= 3 nameLen -= 3
i += 3 i += 3
} else { } else {

18
vendor/github.com/miekg/dns/types.go generated vendored
View file

@ -198,7 +198,7 @@ const (
_CD = 1 << 4 // checking disabled _CD = 1 << 4 // checking disabled
) )
// Various constants used in the LOC RR. See RFC 1887. // Various constants used in the LOC RR. See RFC 1876.
const ( const (
LOC_EQUATOR = 1 << 31 // RFC 1876, Section 2. LOC_EQUATOR = 1 << 31 // RFC 1876, Section 2.
LOC_PRIMEMERIDIAN = 1 << 31 // RFC 1876, Section 2. LOC_PRIMEMERIDIAN = 1 << 31 // RFC 1876, Section 2.
@ -631,8 +631,8 @@ func nextByte(s string, offset int) (byte, int) {
return 0, 0 return 0, 0
case 2, 3: // too short to be \ddd case 2, 3: // too short to be \ddd
default: // maybe \ddd default: // maybe \ddd
if isDigit(s[offset+1]) && isDigit(s[offset+2]) && isDigit(s[offset+3]) { if isDDD(s[offset+1:]) {
return dddStringToByte(s[offset+1:]), 4 return dddToByte(s[offset+1:]), 4
} }
} }
// not \ddd, just an RFC 1035 "quoted" character // not \ddd, just an RFC 1035 "quoted" character
@ -792,7 +792,10 @@ type LOC struct {
// cmToM takes a cm value expressed in RFC 1876 SIZE mantissa/exponent // cmToM takes a cm value expressed in RFC 1876 SIZE mantissa/exponent
// format and returns a string in m (two decimals for the cm). // format and returns a string in m (two decimals for the cm).
func cmToM(m, e uint8) string { func cmToM(x uint8) string {
m := x & 0xf0 >> 4
e := x & 0x0f
if e < 2 { if e < 2 {
if e == 1 { if e == 1 {
m *= 10 m *= 10
@ -848,10 +851,9 @@ func (rr *LOC) String() string {
s += fmt.Sprintf("%.0fm ", alt) s += fmt.Sprintf("%.0fm ", alt)
} }
s += cmToM(rr.Size&0xf0>>4, rr.Size&0x0f) + "m " s += cmToM(rr.Size) + "m "
s += cmToM(rr.HorizPre&0xf0>>4, rr.HorizPre&0x0f) + "m " s += cmToM(rr.HorizPre) + "m "
s += cmToM(rr.VertPre&0xf0>>4, rr.VertPre&0x0f) + "m" s += cmToM(rr.VertPre) + "m"
return s return s
} }

View file

@ -3,7 +3,7 @@ package dns
import "fmt" import "fmt"
// Version is current version of this library. // Version is current version of this library.
var Version = v{1, 1, 52} var Version = v{1, 1, 53}
// v holds the version of this library. // v holds the version of this library.
type v struct { type v struct {

2
vendor/modules.txt vendored
View file

@ -70,7 +70,7 @@ github.com/k-sone/critbitgo
# github.com/kardianos/service v1.2.2 # github.com/kardianos/service v1.2.2
## explicit; go 1.12 ## explicit; go 1.12
github.com/kardianos/service github.com/kardianos/service
# github.com/miekg/dns v1.1.52 # github.com/miekg/dns v1.1.53
## explicit; go 1.19 ## explicit; go 1.19
github.com/miekg/dns github.com/miekg/dns
# github.com/onsi/ginkgo/v2 v2.2.0 # github.com/onsi/ginkgo/v2 v2.2.0